鍍金池/ 問答/HTML/ Vue watch只執(zhí)行一次

Vue watch只執(zhí)行一次

        dayTop:function(val){
            this.deliveryTimeVal=val;
            console.log(this.deliveryTimeVal);
        },
        子組件通過props接收到deliveryTimeVal之后寫的watch事件
                watch: {
                deliveryTimeVal: function (val) {
                console.log(this.deliveryTimeVal);
                }
         但是這個watch事件只能執(zhí)行一次,是什么地方有問題?請大牛指導(dǎo)一下,謝謝
回答
編輯回答
孤巷

props 是單向的,所以,這個問題,你要先說明一下,你是在哪里改變 deliveryTimeVal的值

2017年11月6日 04:59
編輯回答
疚幼

如果deliveryTimeVal不是數(shù)組或者不是對象,那么就不用deep watch,那么你這樣寫就沒什么問題。

2018年6月21日 18:09
編輯回答
苦妄

如果你的deliveryTimeVal是個對象 那么需要watch deliveryTimeVal的時候提供deep:true選項(xiàng)。

2018年5月28日 18:23