by lcrz · 4y ago · 0 comments
Since vue does not hide the fact that something is a ref, you need to call `myRef.value` to get to the underlying value of `const myRef = ref(10)`.
In a new and currently experimental syntax, you can use `const myRef = $ref(10)`, at which point you can just use `myRef` directly. This will then be converted by the Vue SFC compiler.
Another option is to use a reactive object as the state: `const state = reactive({ myVal: 10 })`, at which point you can just use `state.myVal`.
Oh sweet didn't know that. I keep forgetting to type `.value` and debugging it wastes a couple of seconds here and there.
https://vuejs.org/guide/extras/reactivity-transform.html#ref...
You use the object the same way you use a js variable.
let st = $ref(10)
st = st + 1 // update it and use it like if it was just "10"
But now, st is reactive.