I am currently working on a layout where I need to loop through text fields and buttons. How can I implement a function for each button that clears only the corresponding fields? Take a look at this fiddle here.
<div id="app">
<h2>Each text field should have its own state and clicking the clear button should only clear that specific field</h2>
<ul v-for="todo in todos">
<li>
<input type="text" :placeholder="`${todo.text}`">
</li>
<li>
<input type="text" :placeholder="`${todo.text1}`">
</li>
<button>Clear</button>
</ul>
new Vue({
el: "#app",
data: {
todos: [
{ text: "Learn JavaScript", text1:"Hey" },
{ text: "Learn Vue", text1:"Hello" },
{ text: "Play around in JSFiddle", text1:"Ciao" },
{ text: "Build something awesome", text1:"Something"}
]
}
})