美文网首页
vue watch监听数据,新老值一样?让其不一样吧!

vue watch监听数据,新老值一样?让其不一样吧!

作者: hui树 | 来源:发表于2020-10-19 17:01 被阅读0次

https://blog.csdn.net/chenjing0823/article/details/96429867

不过遇到上传图片 对象里带有file图片格式的 不能用JSON.parse(JSON.stringify(this.testData))深拷贝原对象 

```
data:{

        testData:{

            dataInfo:{

                a: '我是a',

                b: '我是b'

            }

        }

    },

    watch: {

      testDataNew: {

        handler: (val, olVal) => {

          console.log('我变化了', val, olVal)

        },

        deep: true

      }

    },

    computed: {

      testDataNew() {

        return JSON.parse(JSON.stringify(this.testData))

      }

    }

```

相关文章

网友评论

      本文标题:vue watch监听数据,新老值一样?让其不一样吧!

      本文链接:https://www.haomeiwen.com/subject/zjflmktx.html