1👍
✅
You can use v-model
or else you need @input
along with :value
:
const app = Vue.createApp({
data() {
return {
my_items: []
};
},
mounted() {
this.my_items = [{id: 1, name: 'name1'}, {id: 2, name: 'name2'}
];
},
methods: {
edit(item) {
console.log("item", item);
},
}
})
app.mount('#demo')
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<div id="demo">
<div v-for="item in my_items" :key="item.id">
<div>
<input type="text" v-model="item.name" />
</div>
<div>
<button @click="edit(item)">Edit</button>
</div>
</div>
</div>
Source:stackexchange.com