Back to list

Vue 3 Composition API

Lv.5537@mukitaro10 playsDec 28, 2025

Vue 3 Composition API component. Modern Vue.js reactive programming.

preview.js
JavaScript
1import { ref, computed, onMounted, watch } from 'vue';
2
3export default {
4 setup() {
5 const count = ref(0);
6 const message = ref('Hello Vue 3');
7
8 const doubleCount = computed(() => count.value * 2);
9
10 const increment = () => {
11 count.value++;
12 };
13
14 watch(count, (newVal, oldVal) => {
15 console.log(`Count changed: ${oldVal} -> ${newVal}`);
16 });
17
18 onMounted(() => {
19 console.log('Component mounted');
20 });
21
22 return {
23 count,
24 message,
25 doubleCount,
26 increment
27 };
28 }
29};

Custom problems are not included in rankings