当前路由显示时,跳转同路由的不同参数,会出现参数变化,页面不刷新。例如:
http://localhost:5000/TaskIndex/TaskList?index=1
http://localhost:5000/TaskIndex/TaskList?index=2
解决办法:
watch: {
'$route' (to, from) { //监听路由是否变化
if(to.query.index!= from.query.index){
this.link();//重新加载数据
}
}
}
this.link()为定义的事件,
当路由上index参数发生变化,触发link事件,从新请求刷新页面数据