mp-router-interceptor
v0.0.7
Published
为mpvue提供router插件,为push,replace,switchTab提供beforeEach,afterEach两个常用的路由守卫
Downloads
3
Maintainers
Keywords
Readme
#Demo
// 定义routes
const router = new mpRouter({
routes: [
{
name: 'policyMain',
path: '/pages/policy/main'
}
]
})
// 在初始化Vue时引用router
const app = new Vue({
// 省略若干...
router
});
// 跳转到指定的路由
this.$router.push({
name: 'policyMain'
})
//使用路由守卫
router.beforeEach(async (to, from, next)=>{
//do sth
})
router.afterEach(async (to, from)=>{
//do sth
})