本文主要是介绍Avoid mutating a prop directly since the value will be overwritten whenever the paren,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
[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中副本来实现,比如
这篇关于Avoid mutating a prop directly since the value will be overwritten whenever the paren的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!