[Vuejs]-How can I save multiple value in v-model on vue.js 2?

0👍

Hi please look at this https://jsfiddle.net/p8zhrg6g/29/ .

<div v-for="item in list">
    <input type="checkbox" :id="item.id" :value="item.value" v-model="checkedNames">
    <label :for="item.id">{{item.value}}</label>

This is how I would have done it, hope this helps?

0👍

Just put value in array in :value..

<div v-for="item in list">
    <input type="checkbox" :id="item.id" :value="[item.name, item.value]" v-model="checkedNames">
    <label :for="item.id">{{item.value}}</label>

When you want call the value in another element, you can call value based on their value index like {{item[0]}} will display item.name and {{item[1]}} will display value.value

Leave a comment