Slide 16
Slide 16 text
ެࣜͷαϯϓϧΛݟͯΈΔ
import { value, computed, watch, onMounted } from 'vue-function-api';
export default {
setup() {
// State
const count = value(0);
// computed state
const plusOne = computed(() => count.value + 1);
// Method
const increment = () => {
count.value++;
};
// watch
watch(
() => count.value * 2,
val => {
console.log(`cont * 2 is ${val}`);
},
);
onMounted(() => {
console.log("mounted");
});
return {
count,
plusOne,
increment
};
},
};