H
H
Horus1232020-06-19 21:34:33
Vue.js
Horus123, 2020-06-19 21:34:33

How to change the value of a string in a component?

The parent component renders the child component:

newString(v-for='(item, index) in stringslist.' 
                :key='item.id' 
                :info='item' 
                @delete-string="deleteString(index)"


The values ​​are taken from the stringslist array. In the array, the objects with the value name.

child component
.example__wrapper
            .example__name(v-if="!changeName") {{info.name}}
            .example__name_change(v-else)
            ul.example__actions
                li.example__edit edit
                li.example__delete(@click="removeCell") delete

changeName: false


How to add change method to child component if array is created in parent component.
Received and added the value to the array in the parent, and now you need to change it in the child and pass it back to the parent array.
I figured out the removal, but I can't change the value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-06-19
@Horus123

PUG, my God, it's good that I dumped him, what a horror, how do you live with him? -_-
down (parent->child) props are slid,
up (child>parent) events
so add change event

newString(v-for='(item, index) in stringslist.' 
                :key='item.id' 
                :info='item' 
                @delete-string="deleteString(index)"
                @change="onChange(index, $event)"

and let the child send a data change event to the top, and change it in the parent, then they will update themselves

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question