uniapp 小程序 监听全局路由跳转 获取路由参数
- app.vue中 api文档
onLaunch: function(options) {let that = this;let event = ['navigateTo', 'redirectTo', 'switchTab', 'navigateBack'];event.forEach(item => {uni.addInterceptor(item, { //监听跳转//监听跳转success(e) {that.watchRouterSuccess()},})})},
methods: {watchRouterSuccess() {const pages = getCurrentPages();const currentPage = pages[pages.length - 1];let path = currentPage.$page.fullPathconsole.log(path,"这个是完整的跳转路径,可获取参数")},
}
- 搞定!亲测有效