Is it possible to dynamically set up v-model using v-for with dynamic keys? The current code does not seem to update the model as expected.
I am working within the Vuetify framework.
Here is my code snippet:
Template
<v-card v-for="(value, key) in myData">
<v-checkbox v-model='selected[key]' :name="key" ></v-checkbox>
</v-card>
Script
export default {
props: {
myData : Object
},
data: function(){
return {
selected: {},
active: null,
}
},
methods: {
setModels: function()
{
let data = this.myData;
let sel = this.selected;
Object.keys(data).forEach(function(key){
if(typeof data[key]== 'object')
{
sel[key] = []
}
});
},
},
mounted() {
this.setModels();
}
}