V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xiaohantx
V2EX  ›  问与答

想问下 el-table 的 v-if 的问题

  •  
  •   xiaohantx · 2022-04-20 18:04:50 +08:00 · 552 次点击
    这是一个创建于 1166 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <el-table-column :key="Math.random()" v-if="[0,1,2,3,4].includes(info.index)"  align="center" type="selection" width="60" :selectable="checkboxSelect" disabled />
            <el-table-column
              v-for="(col,index) in gridDataOne"
              :key="index"
              :prop="col.prop"
              :label="col.label"
              :width="col.width"
              align="center"
              :show-overflow-tooltip="true"
            />
            <el-table-column v-if="[0,1,2,3,4].includes(info.index)" class="version-td" label="注册 ID" prop="stationNum" width="auto" />
            <el-table-column v-if="[4].includes(info.index)" class="version-td" label="物联网卡" prop="simCardId" width="auto" :show-overflow-tooltip="true" />
            <el-table-column v-if="[6].includes(info.index)" class="version-td" label="区域类型" width="auto" :show-overflow-tooltip="true">
              <template slot-scope="scope">
                {{ scope.row.customConfigData ? scope.row.customConfigData.deviceType : '' }}
              </template>
            </el-table-column>
    

    当前 info.index === 6 这是一个代码段,我如果不加:key="Math.random()"那么第一个多选就会显示,不受 if 控制,如果直接删掉,后面内容就会顶到前面但是标题栏还会有个多选框显示,加了:key="Math.random()"都正常了,想了解下原因。。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   875 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:41 · PVG 03:41 · LAX 12:41 · JFK 15:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.