vue路由只变化参数页面组件不更新问题, 例如:
http://localhost:8080/web.html?classid=36
http://localhost:8080/web.html?classid=37
http://localhost:8080/web.html?classid=38
解决办法:
使用watch监听路由$route对象属性的变化
watch: {
'$route':function(to, from) {
this.classid = this.$route.query.classid;
//请求接口数据开始
this.$http.post("http://ncyateng.cn/api/web",
{classid:this.$route.query.classid},
{emulateJSON:true})
.then((response)=>{
console.log(response.data);
this.classid = response.data.classid;
})
//请求接品数据结束
}
}
