vue中 this.A = this.B会改变B的值怎么办

    xiaoxiao2023-10-23  149

    解决方法:

    this.A=JSON.parse(JSON.stringify(this.B));

    里面的this.A= JSON.parse(JSON.stringify(this.B)); 如果是直接this.A= this.B的话会把 this.A替换为this.B然后再把this.B赋值给this.A相当于 this.A= this.A所以先转json字符串 再转数组 然后赋值给this.A这样不会相互影响

    最新回复(0)