Skip to content

Commit 4336b3e

Browse files
committed
docs: clarify once/skip usage
1 parent c74c645 commit 4336b3e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: docs/api/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ These attributes define specific features when used in a metaInfo property
614614

615615
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.
616616

617+
> `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.
618+
617619
```js
618620
{
619621
metaInfo: {
@@ -625,6 +627,24 @@ When adding a metaInfo property that should be added once without reactivity (th
625627
}
626628
}
627629
```
630+
or in combination with `skip`
631+
```js
632+
let theJsHasBeenAddedSoSkipIt = false // <-- outside the component scope
633+
634+
export default {
635+
...
636+
head() {
637+
const skip = theJsHasBeenAddedSoSkipIt
638+
theJsHasBeenAddedSoSkipIt = true
639+
640+
return {
641+
script: [
642+
{ once: true, skip, src: '/file.js' }
643+
]
644+
}
645+
}
646+
}
647+
```
628648

629649
### skip <Badge text="v2.1+"/>
630650

0 commit comments

Comments
 (0)