2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-11 23:42:24 +03:00

docs: clarify once/skip usage

This commit is contained in:
pimlie
2020-02-26 19:42:18 +01:00
parent c74c645d18
commit 4336b3e13e
+20
View File
@@ -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.
> `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
{
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+"/>