template中 如何在循环偶数时加标签 奇数不加?

<template v-for="(item, index) in members">
  <el-row>
    <el-col>
        {{item.name}}
    </el-col>
     <el-col>
        {{members[index+1].name}}
    </el-col>
  </el-row>
</template>
<template v-for="(item, index) in members">
  <el-row style="display: flex" v-if="index % 2 == 0" :key="index">
    <el-col>
    </el-col>
    <el-col v-if="members[index + 1]">
    </el-col>
  </el-row>
</template>
阅读 1.7k
2 个回答

你的标签是哪个?item.name?
<e-col v-if="index%2==0">{{item.name}}</e-col>

index % 2 === 0

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题