docs: warn about ref unwrapping when auto-importing refs (#27933)

This commit is contained in:
Typed SIGTERM 2024-07-01 16:38:03 +08:00 committed by Daniel Roe
parent 3057a04ef0
commit 1d2c0a404a
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -105,6 +105,11 @@ Nuxt directly auto-imports files created in defined directories:
:link-example{to="/docs/examples/features/auto-imports"} :link-example{to="/docs/examples/features/auto-imports"}
::warning
**Auto-imported `ref` and `computed` won't be unwrapped in a component `<template>`.** :br
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals.html#caveat-when-unwrapping-in-templates).
::
### Explicit Imports ### Explicit Imports
Nuxt exposes every auto-import with the `#imports` alias that can be used to make the import explicit if needed: Nuxt exposes every auto-import with the `#imports` alias that can be used to make the import explicit if needed: