R
R
raisatic1552021-08-25 12:55:33
Vue.js
raisatic155, 2021-08-25 12:55:33

Doesn't output v-for through an array?

There is a layout:

<el-form :model="gameMode" :rules="rules" ref="gameMode" label-width="200px" class="demo-ruleForm">
<el-col class="col-time" :span="3" v-for="(day,index) in days" :key="day">
                            <el-row :gutter="20">
                                <el-col>
                                    <div class="grid-content bg-purple">{{day}}</div>
                                </el-col>
                            </el-row>
                            <el-row :gutter="20" v-for="(item,index2) in gameMode.shedules[index]" :key="index2">
                                <el-col>
                                    <el-form-item :prop="'shedules.'+index+'.' + index2" :rules="{required:true,  message: 'Required', trigger: 'blur'}">
                                        <el-input v-model="gameMode.shedules[index][index2]" v-mask="'##:##'"></el-input>
                                        <el-button class="btn-delete" type="danger" size="mini" icon="el-icon-delete" circle v-on:click="gameMode.shedules[index].splice(index2, 1)"></el-button>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-button type="primary" icon="el-icon-plus" circle @click="addTime(index)"></el-button>
                        </el-col>
<el-form/>

{{day}} is displayed correctly, but the second one where v-model="model.shedules[index][index2]" does not display anything, although the array contains this data when added via addTime();

js:
gameMode: {
                    shedules:[
                        [],
                        [],
                        [],
                        [],
                        [],
                        [],
                        []
                    ]
                }...
  addTime(index){

                if(!this.gameMode.shedules[index])
                    this.gameMode.shedules[index] = [];

                this.gameMode.shedules[index].push('');
            }

what could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
raisatic155, 2021-08-25
@raisatic155

I solved the problem, in the array, due to fetch () from php, the array was overwritten, and as a result, the variable that was in gameMode was not obtained,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question