I have an input text field with a v-model attached, and every time someone hits the \"Add\" button, another input text get added to the DOM with the same v-model attached. I tho
Here's a demo of the above:https://jsfiddle.net/sajadweb/mjnyLm0q/11
new Vue({
el: '#app',
data: {
users: [{ name: 'sajadweb',email:'sajadweb@outlook.com' }]
},
methods: {
addUser: function () {
this.users.push({ name: '',email:'' });
},
deleteUser: function (index) {
console.log(index);
console.log(this.finds);
this.users.splice(index, 1);
if(index===0)
this.addUser()
}
}
});
Add user
{{ $data }}