I have the following component and would like to set the type and default value for editing
, which gets toggled to display either Item
values or an <input>
:
Vue.component('item', {
props: {
'item': Item,
'editing': {
type: Boolean,
default: false
},
},
data: function() {
return {
_cachedItemText: '',
}
},
methods: {
The following warning results when the value of editing
gets toggled by pressing an Edit
button (not shown).
[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: "editing"
In the Props
documentation, there's an example showing how to set the type, default value and validator for a prop. Is there an analogous way to set these attributes for a data item?
Also, I'm not passing editing
in from the parent component, so I don't think it really needs to be a prop instead of a data item.
item
both as a component name and a prop name. – Husam Ibrahim