Answer the question
In order to leave comments, you need to log in
How to update the value in an array element?
Given this json array
inputs: [
{ label: 'Продавец', label1: 'Покупатель', type: 'text', name: 'seller'},
{ label: 'Полное наименование продавца', label1: 'Полное наименование покупателя', type: 'text', name: 'fullname'},
]
this.inputs.forEach((value, index) => {
this.$set(this.inputs, index, {label: value.label1})
});
Answer the question
In order to leave comments, you need to log in
If you want to do exactly as you have written, then here is an option:
this.inputs.forEach((value, index) => {
this.$set(this.inputs, index, {...value, label: value.label1})
});
this.inputs = this.inputs.map(item => ({ ...item, label: item.label1 }))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question