data:data:function?()?{
????return?{
????????articleList:null,
????????tagList:null,
????????checkedArticleList:[],//選中的文章
????????//列表數據顯示的條件
????????condition:{
????????????page:{
????????????????start:1,
????????????????count:5,
????????????????total:0
????????????},
????????????condition:{
????????????????desc:false,
????????????????whereFields:[],//篩選條件
????????????????sortByPublishTime:false,
????????????????sortByTopicId:false,
????????????????sortByPageViews:false
????????????}
????????}
????}
}watch1:watch:{
????condition:{
????????handler:function?(val,oldVal)?{
????????????console.log(val);
????????????this.getArticleList();
????????},
????????deep:true
????}
},這里會無限觸發handler在控制臺對比其中的屬性,沒有改變watch2:watch:{
????'condition.condition':{
????????handler:function?(val,oldVal)?{
????????????console.log(val);
????????????this.getArticleList();
????????},
????????deep:true
????}
},這里是正常觸發watch3:watch:{
????'condition.page':{
????????handler:function?(val,oldVal)?{
????????????console.log(val);
????????????this.getArticleList();
????????},
????????deep:true
????}
},這里是無限觸發handler問題就出在這個page屬性,對比了其中的屬性也沒有發生改變,但是有其他的變化在兩個截圖上可以看到dep屬性的id發生了改變,不知道vue是不是通過這個來判斷屬性的變化,這個可能涉及到vue的原理吧,但是很納悶watch2:就不會無限觸發,希望慕課大牛們指點一二呀
Vue.js 中深度觀察
暴躁的代碼
2017-07-10 12:09:57