1.0.6 • Published 2 years ago
lazy-uni-router v1.0.6
uniapp 关于 跳转页面方法的 封装
缺点:守卫监听不到左上角返回事件
A:自定义 navigationBar组件 B:使用wx.navigateTo的events,结合wx.onAppRoute 来实现
引入
import router from 'lazy-uni-router';
初始化
//前置守卫
router.beforeEach(function(to, from, params, next) {
next()
})
//后置守卫
router.afterEach(function(to, from, params) {
})
文档
//跟原生方法一致,只不过将uni替换成router
router.navigateTo(url, params, options)
// 获取路由页面参数和路由
console.log(router.getParams()) //参数
console.log(router.getCurrentPath()) //获取当前页面的路由
console.log(router.getFromPath()) //跳转前的页面
console.log(router.getToPath()) //跳转的页面