Vue dynamically generates elements

clipboard.png
one click to add requires an input, and can bind data. How to implement

Apr.16,2021

The idea of

vue is not to generate elements dynamically, but to change the view by changing the data.

take a chestnut. At first, your data structure is that the medical history array under the disease is empty, the length of the medical history array is 1 after clicking, and then through the v-for loop to find out how many input you have.


<div v-for="item in items">
    <input />
</div>

where items is the component list.
you can push a component to this.items every time you click

.
onClick() {
    this.items.push(1)
}
Menu