【发布时间】:2019-11-07 03:27:57
【问题描述】:
我在浏览器中不断收到此错误Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "dataElements"
我的组件中有@Prop() private dataElements: any[];。这个 prop 是由 parent 和 child 改变的,当它改变时它可能需要一个 watcher 来做一些操作。
如何从中创建计算属性?
【问题讨论】:
-
@Rich 有点是,有点不是。我使用 Typescript,所以我不能使用那里提供的解决方案。我需要 Typescript 中的解决方案,而不是 Javascript 中的解决方案。我会自己进行转换,但我不太了解 Vue。
标签: typescript vue.js