[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the paren

 

在vue2.0中子组件触发改变值的时候vue组件会报出例如:

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: "showStaffList"的错误。

原因:

简单的说就是,组件内不能修改props的值

解决方法:

在data中创建一个props值得副本,所有操作props值得地方都通过操作data中副本来实现,比如

 

 

 

 

 
Logo

前往低代码交流专区

更多推荐