My use case
- I got an array from back-end API which contains input field names.
- I render these names along with a input field.
This is my code.
<template>
<div class="itemGenerate">
<div>
<ul>
<li v-for="identifier in identifiers" :key="identifier">
<input type="text" value=""/>{{identifier.name}}
</li>
</ul>
<button type="button">Add</button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
identifiers: [{ name: "Flavour" }, { name: "Size" }, { name: "Color" }]
};
}
};
My question is
these input fields are not constant. It'll change in each and every API call (some times it's only color sometimes color,size and another new thing).
I would use v-model if I know the number of input fields, but I cannot use here because it's not predefined.
How do I achieve this using vue.js?