父組件:<parent :date_schedule="date_schedule"></parent>子組件:props: {
date_schedule:{ type:Array, default: []
},
},
data () { return {
...
}
},
watch: {
date_schedule: {
handler(newVal,oldVal) { console.log(newVal) console.log(oldVal) //console.log('date_schedule:update');
//this.update_calendar_schedule();
},
deep: true
},
table_data: {
handler(value) { //console.log('table_data:update');
//this.update_calendar_schedule();
},
deep: true
},
},
computed: {
table_data:{ get: function() { return this.date_schedule;
}, set: function(value) { console.log(value);
}
},
},子組件中使用table_data來(lái)渲染出一個(gè)table。當(dāng)父組件的date_schedule修改時(shí),子組件的date_schedule和table_data都有變化,但是子組件中的table視圖卻不隨變化而更新,顯示的永遠(yuǎn)是還是上一次table_data數(shù)據(jù)。我知道是數(shù)據(jù)檢測(cè)變化的問(wèn)題,但始終找不出是哪里的問(wèn)題,請(qǐng)大家?guī)兔匆幌聗謝謝了
子組件computed屬性改變視圖不改變
哆啦的時(shí)光機(jī)
2019-03-19 19:36:07