Answers for "vue composition api"

6

vue 3 composition api watch

// directly watching a ref

const selected = ref(props.selected)

watch(selected, (selection, prevSelection) => { 
   /* ... */ 
})
Posted by: Guest on August-25-2020
1

vue composition api

<template>
  <button @click="increment">
    Count is: {{ state.count }}, double is: {{ state.double }}
  </button>
</template>

<script>
import { reactive, computed } from 'vue'

export default {
  setup() {
    const state = reactive({
      count: 0,
      double: computed(() => state.count * 2)
    })

    function increment() {
      state.count++
    }

    return {
      state,
      increment
    }
  }
}
</script>
Posted by: Guest on November-04-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language