Skip to content

Commit 4e4bce3

Browse files
committed
fix(hook): hook
fix hezhongfeng#25
1 parent f2ed83e commit 4e4bce3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-page-stack",
3-
"version": "1.3.2",
3+
"version": "1.4.0",
44
"description": "Routing and navigation for your Vue SPA. Vue 单页应用导航管理器",
55
"author": "hezf",
66
"scripts": {

src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ VuePageStackPlugin.install = function(Vue, { router, name = config.componentName
2222
throw Error('\n vue-router is necessary. \n\n');
2323
}
2424
Vue.component(name, VuePageStack(keyName));
25-
25+
2626
Vue.prototype.$pageStack = {
2727
getStack
2828
};
2929

3030
mixin(router);
31-
function intercept(to, from, next) {
31+
32+
function beforeEach(to, from, next) {
3233
if (!hasKey(to.query, keyName)) {
3334
to.query[keyName] = getKey('xxxxxxxx');
3435
let replace = history.action === config.replaceName || !hasKey(from.query, keyName);
@@ -51,9 +52,8 @@ VuePageStackPlugin.install = function(Vue, { router, name = config.componentName
5152
next({ params: to.params });
5253
}
5354
}
54-
router.beforeEach(intercept);
55-
let index = router.beforeHooks.findIndex(hook => hook === intercept)
56-
router.beforeHooks.unshift(router.beforeHooks.splice(index, 1)[0])
55+
56+
router.beforeHooks.unshift(beforeEach);
5757
};
5858

5959
export default VuePageStackPlugin;

0 commit comments

Comments
 (0)