Vue js 数组绑定

问题描述

<div class="col-4" v-for="(section,index) in sections" :key="section.id">
    <div class="card">
        <div class="card-header"><h6 v-text="section.name_ar + ' - '+ index"></h6></div>
        <div class="card-body">
            <multiselect :options="packageMeals.filter(x => x.pivot.section_id == section.id && x.pivot.week_index == moment(day.date).format('dddd')).map(x=>x.id)"
                         :custom-label="opt=> packageMeals.find(x=>x.id==opt).name_ar" v-model="meals[index][0]"
            ></multiselect>
        </div>
    </div>
</div>
data: function () {
    return {
        collapse: true,meals: new Array(this.sections.length).fill(new Array(3)),}
},mounted() {

},methods: {
    SaveDay() {

    },moment: function (date) {
        return window.moment(date)
    },},

这里我想将选定的选项绑定到餐点[index][0]。但它有界于meals数组中的所有元素,例如: 它现在绑定到餐 [0][0]、餐 [1][0]、餐 [2][0]、.... 因此,当仅更改餐点[0][0] 的输入时,所有其他输入都会更改。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)