[Vuejs]-Someone can explain me what "ref()" function do?

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!")
}

Leave a comment