[Vuejs]-How to reference to an object inside of array with value and use it in v-model

0👍

You should add computed prop and gather item.metas and customFields there:

computed: {
  customFieldsAndMetas () {
     return this.customFields.map(x => ({
       field: x,
       meta: this.item.metas.find(i => i.key === field.systemName)
     }))
  }
}

and use it in a template like this:

<div v-for="fieldAndMeta in customFieldsAndMetas">
  <input v-model="fieldAndMeta.meta.value" :label="fieldAndMeta.field.systemName" :placeholder="fieldAndMeta.field.systemName" type="text">
</div>

Leave a comment