最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Element-UI?el-table對循環(huán)產(chǎn)生的空白列賦默認值方式

 更新時間:2024年03月01日 08:41:54   作者:小雅痞  
這篇文章主要介紹了Element-UI?el-table對循環(huán)產(chǎn)生的空白列賦默認值方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

Element-UI el-table對循環(huán)產(chǎn)生的空白列賦默認值

el-table 空白列賦值

對el-table中未傳數(shù)據(jù)存在空白的列賦默認值0。

使用el-table 提供的插槽 slot-scope:{{ row || '0' }}

原數(shù)據(jù):

圖1

<el-table-column label="集鎮(zhèn)"  :prop=city >
     <template slot-scope="{row}">
         {{ row || '0' }}
       </template>
</el-table-column>

el-table 對循環(huán)產(chǎn)生的空白列賦值

對于循環(huán)產(chǎn)生的列,仍要賦默認值0,可采用以下方式: {{ row[col.city] || '0' }}

原數(shù)據(jù):

圖2

<template v-for="col in cols">
   <el-table-column :label=col.label>
     <el-table-column label="集鎮(zhèn)" :prop=col.city >
       <template slot-scope="{row}">
         {{ row[col.city] || '0' }}
       </template>
     </el-table-column>
     <el-table-column label="農(nóng)村" :prop=col.village>
       <template slot-scope="{row}">
         {{ row[col.village] || '0' }}
       </template>
     </el-table-column>       
   </el-table-column>
</template>

問題解決:

el-table內(nèi)容為空,設置默認值 效果

方法一:通過css設置

/deep/.el-table {
  .cell:empty::before {
    content: "---";
    color: #ccc;
  }
  .is-leaf {
    .cell:empty::before {
      content: "---";
      color: #ccc;
    }
  }
}

方法二:過濾

el-table-column里使用:formatter

<el-table-column
        prop="caseTypeNames"
        label="類型"
        :formatter="caseTypeNamesFormat"
      >
</el-table-column>
    // 類型格式化
    caseTypeNamesFormat (row) {
      let showProp = null
      row.caseTypeNames ? showProp = row.caseTypeNames : showProp = '---'
      return showProp
    },

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論

安康市| 冷水江市| 弋阳县| 乌兰察布市| 盐津县| 三门峡市| 满洲里市| 梁平县| 旺苍县| 新竹县| 龙海市| 于都县| 邯郸县| 行唐县| 唐海县| 专栏| 黄浦区| 商都县| 达尔| 长泰县| 西乌| 自贡市| 资溪县| 海城市| 汉阴县| 峡江县| 师宗县| 贞丰县| 永和县| 红河县| 普兰店市| 会泽县| 平谷区| 佛冈县| 兴化市| 会宁县| 临泽县| 九台市| 尉氏县| 峨眉山市| 青海省|