The vue child component modifies the value of the parent component

how can I change the value passed by the v-for loop of the parent component if the child component wants to modify it?

clipboard.png

clipboard.png
how do I modify this value? Because I don"t know the location of the value

Mar.12,2021

then you pass the location to the child component. When you need to modify it, notify the parent component to change it, and pass the data and index to


.

I only know that there are two types of

when I want to modify the props from the parent component in the child component.
  • by passing a callback on the child component, eg.
// par
<Par>
    <Child v-model="number" />
</Par>

// child
export default {
    model: {
        prop: number,
        event: 'handleChange',
    },
    props: ['number'],
    methods: {
        ['']() {
            this.$emit('handleChange', );
        }
    }
}

if there are other ways, you are welcome to communicate

Menu