I have array with components data and try render it with v-for
<div :style="style" class="editor-component" v-for="(component, index) in components">
<Component
:is="component.name"
v-bind="component.options"
:key="createKey(component, index)"
:style="component.style ? component.style : {}"
/>
</div>
So problem:
When component.options has array prop with 1 element, like
tabs: [{tab}]
it's works nice, but when tabs have 2 and more tab, like this
tabs: [{tab},{tab}]
Component don't watch changes in second tab.
So, i solved it with dinamical key
createKey(component, index) {
return JSON.stringify(component) + index
}
but it makes component re-render after each change, and reset component state to default.
UPD: I've found same problem Reactive Nested V-For's using Vue/Vuex but it hasn't answer :(
key
before? For reactivity it is also important to see, how you change the data. Can you please post that code? - bodo@Mutation setComponent(component: PageComponent) { let index = this.components.findIndex(i => (i.name === component.name) && i.edit); Vue.set(this.components, index, component); }
- Андрей Луговскойcomponents
is an array, try adding the data withcomponents.push
. - bodo