How to dynamically add subcomponents and take values through click events

clipboard.png
as shown in the figure, the content of the parent component is shown. The requirement now is that every time you click to add a professional qualification certificate, the parent component will have more content as shown in the red area. I write the red area as a component, reference it within the parent component, want to know how to refer to it more than once per click, and the most important thing is how I get the value of a child component that has been referenced multiple times (for example, I have referenced this component three times. How to get all the values)

Sep.18,2021

vue is data-driven, and your component content should be traversed by v-for:

<template>
    <div v-for='item in arr'>
            <select v-model='item.a'></select>
            ....
    </div>
</template>
<script>
    ...
        arr:[{},{}]//arr
    ...
</script>

in this way, your click event can only add the value in the array arr, and finally take arr is the data you want.


upstairs dei

Menu