vue determined using v-if given length of the array length is the emergence

  • When an error occurs is determined using v-if the length of the array in the vue
<el-collapse-item :key="index"  v-if="data.childrens.length > 0" :title="data.fname" :name="data.fname">
    <el-row>
        <el-col :md="24" :lg="12" :xl="8" v-for="item in data.childrens" :key="item.directoryID"><div :class="treeFlag === item ? 'treeHover' : ''" @click="treeClick(data.fname, item.fname, item.directoryID)">{{ item.fname }}</div></el-col>
    </el-row>
</el-collapse-item>

Given as follows

  • This problem occurs because there is no determination of whether there is an array when the array length is determined

Therefore, the need to add v-if present array is determined, as shown below

Guess you like

Origin www.cnblogs.com/Yancyzheng/p/11909916.html