mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-10 16:52:24 +03:00
feat: add afterNavigation callback (fix: #259)
This commit is contained in:
@@ -30,6 +30,6 @@ export default function _refresh(options = {}) {
|
||||
metaInfo.changed.call(this, metaInfo, tags.addedTags, tags.removedTags)
|
||||
}
|
||||
|
||||
return metaInfo
|
||||
return { vm: this, metaInfo, tags }
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -81,7 +81,12 @@ export default function createMixin(Vue, options) {
|
||||
next()
|
||||
})
|
||||
|
||||
$router.afterEach(() => $rootMeta.resume())
|
||||
$router.afterEach(() => {
|
||||
const { vm, metaInfo } = $rootMeta.resume()
|
||||
if (metaInfo && metaInfo.afterNavigation && isFunction(metaInfo.afterNavigation)) {
|
||||
metaInfo.afterNavigation.call(vm, metaInfo)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,4 +1,4 @@
|
||||
import { isObject } from './typeof'
|
||||
import { isObject, isFunction } from './typeof'
|
||||
|
||||
import {
|
||||
keyName,
|
||||
@@ -29,5 +29,15 @@ export default function setOptions(options) {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.afterNavigation && !isFunction(options.afterNavigation)) {
|
||||
console.warn(`afterNavigation should be a function, received ${typeof options.afterNavigation} instead`) // eslint-disable-line no-console
|
||||
options.afterNavigation = void 0
|
||||
return options
|
||||
}
|
||||
|
||||
if (options.afterNavigation && !options.refreshOnceOnNavigation) {
|
||||
options.refreshOnceOnNavigation = true
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user