router跳转始终带参数,main.js:
router.beforeEach((to, from, next) => {
//判断该页面有 id
if(from.query.authorisationId){
//路由切换时,如果没有就添加,有就跳过执行,添加固定参数
if (!to.query.authorisationId) {
//准备一个跳转的query对象
let query = to.query
query.authorisationId = from.query.authorisationId
next({
path: to.path,
query: query
})
} else {
next()
}
}else{
next()
}
})