Open3
Vue.js V3 の Composition API 忘れたときに見るスクラップ
Data (Reactive Variables)
import { ref } from 'vue'
const counter = ref(0)
console.log(counter) // { value: 0 }
console.log(counter.value) // 0
Method
import { ref } from 'vue'
const counter = ref(0)
console.log(counter.value) // 0
const increment = () => ++counter.value
increment()
console.log(counter.value) // 1
Computed
import { ref, computed } from 'vue'
const counter = ref(1)
const twiceTheCounter = computed(() => counter.value * 2)
console.log(counter.value) // 1
console.log(twiceTheCounter.value) // 2