报错:Avoid mutating a prop directly since the value will be overwritten whenever the parent component

[Vue warn]: 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: "filterStatus"

 

 这个报错的意思是子组件修改了父组件传来的值。

原因:父组件可以有很多的子组件,如果每一个子组件都可以去修改父组件的值,那可能就会引起冲突,但是如果需求中就要改变这个值怎么办呢?

解决:可以在子组件的data里写一个另外的值,用这个值来接收传递过来的值,这样一来这个值变化就不会有错了。

data: function() {return { filterStatus1: this.filterStatus }},


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部