mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 08:20:33 +03:00
Fix beforeMount & destroyed hooks
This commit is contained in:
@@ -38,6 +38,10 @@ export default function VueMeta (Vue, options = {}) {
|
|||||||
// watch for client side component updates
|
// watch for client side component updates
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
beforeCreate () {
|
beforeCreate () {
|
||||||
|
// Add a marker to know if it uses metaInfo
|
||||||
|
if (typeof this.$options[options.keyName] !== 'undefined') {
|
||||||
|
this._hasMetaInfo = true
|
||||||
|
}
|
||||||
// coerce function-style metaInfo to a computed prop so we can observe
|
// coerce function-style metaInfo to a computed prop so we can observe
|
||||||
// it on creation
|
// it on creation
|
||||||
if (typeof this.$options[options.keyName] === 'function') {
|
if (typeof this.$options[options.keyName] === 'function') {
|
||||||
@@ -60,7 +64,7 @@ export default function VueMeta (Vue, options = {}) {
|
|||||||
},
|
},
|
||||||
beforeMount () {
|
beforeMount () {
|
||||||
// batch potential DOM updates to prevent extraneous re-rendering
|
// batch potential DOM updates to prevent extraneous re-rendering
|
||||||
if (this.$metaInfo) {
|
if (this._hasMetaInfo) {
|
||||||
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -68,7 +72,7 @@ export default function VueMeta (Vue, options = {}) {
|
|||||||
// do not trigger refresh on the server side
|
// do not trigger refresh on the server side
|
||||||
if (this.$isServer) return
|
if (this.$isServer) return
|
||||||
// re-render meta data when returning from a child component to parent
|
// re-render meta data when returning from a child component to parent
|
||||||
if (this.$metaInfo) {
|
if (this._hasMetaInfo) {
|
||||||
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user