vue 监听data中数据变化

<script>
export default {
  data(){
    return {
      items:[]
    }
  },
  watch: {
    items: {
      handler(newValue,oldValue) {
        //newValue 改变后的数据
        //oldValue  改变前的数据
      }
      //,deep: true
    }
  }
}
</script>

如果监听对象内部属性改变需要增加deep: true

原文地址:https://www.cnblogs.com/rchao/p/13405424.html