0👍
To make the state reactive
Please check the Vue Docs:
If you use
const globalCount = 1
then the globalCount
is a constant, that is not only not reactive, but also cannot be changed at all.
0👍
The ref() function returns a special reactive object. To access the value that ref() is tracking, we access the value property of the returned object:
import { ref } from 'vue'
const age = ref(0)
if(age.value < 18) {
console.log("You are too young to drink. Get lost!")
} else {
console.log("Have some ale mate!")
}
- [Vuejs]-Vue.js can't copy array to another array
- [Vuejs]-Why does computed change data when assigning data to a variable?
Source:stackexchange.com