DEV Community

niuniu
niuniu

Posted on

Quick Tip: Vue.js Composition API

Quick Tip

Vue.js Composition API cheat sheet:

// Reactive state
const count = ref(0);
const state = reactive({ name: 'Vue' });

// Computed
const double = computed(() => count.value * 2);

// Watch
watch(count, (newVal) => {
  console.log(newVal);
});

// Lifecycle
onMounted(() => {
  console.log('Component mounted');
});
Enter fullscreen mode Exit fullscreen mode

Powered by MonkeyCode: https://monkeycode-ai.net/

vue #javascript #tips

Top comments (0)