router.map({
'/': {
name: 'home',
component: function(reslove) {
return require(['./views/home/index.vue'], reslove)
},
meta:{keepAlive:true}
},
'/cate1/': {
name: 'cate1',
component: function(reslove) {
return require(['./views/category/index.vue'], reslove)
},
meta:{keepAlive:true}
},
'/cate2/': {
name: 'cate1',
component: function(reslove) {
return require(['./views/category/index.vue'], reslove)
},
meta:{keepAlive:true}
},
});
//注册路由切换前
router.beforeEach(function(transition) {
transition.next();
});
//注册路由切换后
router.afterEach(function(transition) {
console.log(transition.from.name)
});
route: {
data(transition){},
deactivate (transition) {
console.log('deactivate...')
transition.next()
}
}
1
xiaomeimei OP 已经解决了,增加一个 canReuse 钩子函数,返回 false,告诉不可重用
```javascript canReuse(transition){ return false } ``` |
2
xiaomeimei OP ```
canReuse(transition){ return false } ``` |