I’m wondering about the best approach on updating a value on which the template is rendered and depending on.
<div v-for="field in fields"> <input v-model="field.name" /> <textarea v-model="post[field.name]" /> </div>
So upon a change in
field.name, vue obviously throws an error because
post[field.name] is not defined anymore.
I was thinking about making a copy of
fields and let the input edit that and the textarea depend on the “original”, but that seems complicated because you would need to keep them in sync all the time.
Is there a better solution?
This seems to be related: Any better way than v-if to render content that is temporarily undefined?
I found that using a 1-way binding (using
:value) is the first step to go. Other than that, it still throws errors, becaue
post[field.name] is temporarily undefined.