Unwrapping refs in Vue - exception

Published on: Tuesday, 02.01.2024

Refs are automatically unwrapped in the template tag if they are top-level properties in the rendering context.
This doesn't apply when using ref as object properties. For those, we can either use destructuring or .value property.

const object = { id: ref(1) } {{ object.id + 1 }} // will not work in the
template tag
const { id } = object {{ id + 1 }} // works after destructuring