<div id="app">
<h2>Todos:</h2>
<ol>
<li v-for="todo in todos">
<label>
<input v-model="todo" >
</label>
</li>
</ol></div>new Vue({
el: "#app",
data: {
todos: [1,2,3]
},
watch:{
todos: {
handler(newValue, oldValue) {
for (let i = 0; i < newValue.length; i++) {
if (oldValue[i] != newValue[i]) {
alert(newValue)
}
}
},
deep: true
}
}, methods: { toggle: function(index,e){ alert(e)
}
}
})demo:http://jsfiddle.net/9hmndL4x/點(diǎn)擊預(yù)覽 改變input里邊的值沒有觸發(fā)watch
vue數(shù)組綁定的input值發(fā)生變化時(shí)watch沒有監(jiān)聽到?
ibeautiful
2019-03-01 21:02:50