Search code examples
javascriptvue.jsv-model

Using v-model to dynamic variable


I am trying to use v-model to spesific properties in an object, but the syntax on v-model is not right. selectBind and values.select is the same length.

var selectBin = ["fileName", "subTitle"]

<b-row v-for="(select, index) in values.selects" :key="select.index">
    <Select
        :label="select.label"
        :index="index"
        :name="select.name"
        :options="select.values"
        v-model="scheduals.data.`${selectBind[index]}`"
        //this should be the same as v-model="scheduals.data.fileName" and v-model="scheduals.data.subTitle"
                                            
 />
</b-row>```

Solution

  • Try out to access the property using [] accessor :

    v-model="scheduals.data[[selectBind][index]]"