假如当前路径为: http://localhost:8080/detail?goodsId=5e6de2ad3f9b1668a0f37e88
需要跳转路径为: http://localhost:8080/detail?goodsId=5e6de2573f9b1668a0f37e87
只需要在显示页面中添加 watch 监听 $route
对应函数进行重新获取当前 vue-router 传的参数对应的路径:
watch: {
// 如果路由有变化,会再次执行该方法
'$route': 'fetchData'
},
fetchData () {
console.log("进入页面再次执行的方法")
}
参考链接: