I want to assign different and unique parameter in loop to each input tag (v-model)
I tried the code below
<template>
<div v-for="item in lst" key="item">
<input :v-model="item"> </input>
</div>
</template>
<script setup>
var lst = ['first_vmodel_value','second_vmodel_value']
</script>
By doing this I want to access to each input tag v-model value. The example above, there are only two item value but actually much more value exists.
- The code above is not working. I want to assign unique v-model value to each input tag.
The intent of the code is to access v-model value using lst item, for example first_vmodel_value or second_vmodel_value
2
Answers
use ref/reactive Object – and it’s
v-model
not:v-model
The content of your
lst
would be used to create properties inmodels
(it’s an arbitrary name)Or possibly it’s better like this
You can create an array of refs.