vue路由钩子函数
一、全局钩子router.beforeEach((to, from, next) => {console.log('beforeEach');});router.afterEach((to, from) => {console.log('beforeEach');});二、单个路由钩子const router = new VueRouter({rout...
·
一、全局钩子
router.beforeEach((to, from, next) => {
console.log('beforeEach');
});
router.afterEach((to, from) => {
console.log('beforeEach');
});
二、单个路由钩子
const router = new VueRouter({
routes: [{
path: '/index',
component: index,
beforeEnter(to, from, next) {},
beforeLeave(to, from, next) {}
}]
});
三、组件钩子
export default {
beforeRouteLeave(to, from, next) {},
beforeRouteEnter(to, from, next) {},
beforeRouteUpdate(to, from, next) {}
};
更多推荐
已为社区贡献1条内容
所有评论(0)