mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 00:00:33 +03:00
docs: clarify once/skip usage
This commit is contained in:
@@ -614,6 +614,8 @@ These attributes define specific features when used in a metaInfo property
|
|||||||
|
|
||||||
When adding a metaInfo property that should be added once without reactivity (thus will never be updated) you can add `once: true` to the property.
|
When adding a metaInfo property that should be added once without reactivity (thus will never be updated) you can add `once: true` to the property.
|
||||||
|
|
||||||
|
> `once` only works reliably during SSR. When using `once` in components, you need to also use `skip` and store a skip status outside of the component scope.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
metaInfo: {
|
metaInfo: {
|
||||||
@@ -625,6 +627,24 @@ When adding a metaInfo property that should be added once without reactivity (th
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
or in combination with `skip`
|
||||||
|
```js
|
||||||
|
let theJsHasBeenAddedSoSkipIt = false // <-- outside the component scope
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...
|
||||||
|
head() {
|
||||||
|
const skip = theJsHasBeenAddedSoSkipIt
|
||||||
|
theJsHasBeenAddedSoSkipIt = true
|
||||||
|
|
||||||
|
return {
|
||||||
|
script: [
|
||||||
|
{ once: true, skip, src: '/file.js' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### skip <Badge text="v2.1+"/>
|
### skip <Badge text="v2.1+"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user