K
K
Kirill Petrov2021-09-09 17:42:07
Vue.js
Kirill Petrov, 2021-09-09 17:42:07

How to correctly write data to an array by key and not lose reactivity?

Hello. I'm trying to write beautiful code, but it doesn't work. I don’t understand how to correctly place references to objects in an array, so as not to copy-paste them a hundred times into memory and not suffer from writing the logic for observing relationships.

Here is an example on JSFiddle: https://jsfiddle.net/m34qhexv/
The top form, how I would like to access objects, but does not work and does not change the data.
The bottom one works.

How to correctly describe relationships for reactivity but not describe each field key?

In general, the complete task, I get a random list of fields from the API and I want to be able to edit it address by key in different parts of the components by specifying a variable in v-model

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2021-09-09
@Rsa97

A
AndromedaStar, 2021-09-10
@AndromedaStar

To catch up, let me remind you that computed has a getter and a setter. Usually beginners forget about it and make scary constructions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question