[Vuejs]-Vue .js v-on:input how to pass parameters(inputted value and the index) to a computed property

2👍

You can use $event to pass the inputted value to process and then you can push it to items. Also, I would use v-one:change instead of v-on:input, because v-on:input calls process for every key press and I don’t think that is something you want.

<ul>
    <li v-for="(item,index) in items" :key="index">
        <input v-on:change="process($event,index)" type="text">{{item}}
    </li>
</ul>

And now we can push it

methods: {
    process(event, index){
        this.items[index].push(event.target.value);
    }
}

Leave a comment