mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 17:00:34 +03:00
add change event
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
- [`style` ([Object])](#style-object)
|
||||
- [`script` ([Object])](#script-object)
|
||||
- [`noscript` ([Object])](#noscript-object)
|
||||
- [`changed` (Function)](#changed-function)
|
||||
- [How `metaInfo` is Resolved](#how-metainfo-is-resolved)
|
||||
- [Performance](#performance)
|
||||
- [How to prevent the update on the initial page render](#how-to-prevent-the-update-on-the-initial-page-render)
|
||||
@@ -485,6 +486,25 @@ Each item in the array maps to a newly-created `<noscript>` element, where objec
|
||||
<noscript>This website requires JavaScript.</noscript>
|
||||
```
|
||||
|
||||
#### `changed` (Function)
|
||||
|
||||
Will be called when the client `metaInfo` updates/changes. Receives the following parameters:
|
||||
- `newInfo` (Object) - The new state of the `metaInfo` object.
|
||||
- `addedTags` ([HTMLElement]) - a list of elements that were added.
|
||||
- `removedTags` ([HTMLElement]) - a list of elements that were removed.
|
||||
|
||||
`this` context is the component instance `changed` is defined on.
|
||||
|
||||
```js
|
||||
{
|
||||
metaInfo: {
|
||||
changed (newInfo, addedTags, removedTags) {
|
||||
console.log('Meta info was updated!')
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### How `metaInfo` is Resolved
|
||||
|
||||
You can define a `metaInfo` property on any component in the tree. Child components that have `metaInfo` will recursively merge their `metaInfo` into the parent context, overwriting any duplicate properties. To better illustrate, consider this component heirarchy:
|
||||
|
||||
Reference in New Issue
Block a user