vue路由只變化參數(shù)頁面組件不更新問題, 例如:
http://localhost:8080/web.html?classid=36
http://localhost:8080/web.html?classid=37
http://localhost:8080/web.html?classid=38
解決辦法:
使用watch監(jiān)聽路由$route對象屬性的變化
watch: { '$route':function(to, from) { this.classid = this.$route.query.classid; //請求接口數(shù)據(jù)開始 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; }) //請求接品數(shù)據(jù)結束 } }