<script> export default { data(){ return { items:[] } }, watch: { items: { handler(newValue,oldValue) { //newValue 改變后的數據 //oldValue 改變前的數據 } //,deep: true } } } </script>
如果監聽對象內部屬性改變需要增加deep: true
下面是簡寫形式 想要監聽對象內部屬性改變不能使用簡寫形式
watch: {
items(newVal, oldVal){
}
}