Skip to content

Commit

Permalink
docs: clarify once/skip usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie committed Feb 26, 2020
1 parent c74c645 commit 4336b3e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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+"/>

Expand Down

0 comments on commit 4336b3e

Please sign in to comment.