H
H
Horus1232020-06-18 08:31:38
Vue.js
Horus123, 2020-06-18 08:31:38

How to draw a new component instance every time on click?

In the project, on click, the component should be added to the list and rendered. How to draw it not once, but every time when clicked?
Now done as a modal window:

newCell(v-if="showCell")
show : false,
showCell () {
        this.show = true;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-06-18
@Horus123

In the parent, set up a counter of child component instances:

data: () => ({
  repeat: 0,
}),

And render the appropriate number of them:
<child-component v-for="i in repeat"></child-component>

If you need to render more - increase the value of the counter:
<button @click="repeat++">add one more child component instance</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question