在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: "content"
1、报错详情 [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: "items_index"
2、错误原因
改动了子组件中引用的父组件的变量,也就是props中的数据
在Vue2中组件props中的数据只能单向流动,即只能从父组件通过组件的DOM属性attribute传递props给子组件,子组件只能被动接收父组件传递过来的数据,并且在子组件中,不能修改由父组件传来的props数据。文章来源:https://www.toymoban.com/news/detail-652217.html
3、解决方案avoid mutating a prop directly since the value will be overwritten whenever
不要直接修改从父组件传过文章来源地址https://www.toymoban.com/news/detail-652217.html
到了这里,关于avoid mutating a prop directly since the value will be overwritten whenever完美解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!