最新国产好看的视频,伊人天堂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
    },

總結(jié)

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

相關文章

最新評論

金寨县| 贵港市| 泌阳县| 军事| 吴川市| 双城市| 静海县| 黎川县| 宝鸡市| 临沭县| 贵州省| 康保县| 西峡县| 江源县| 古蔺县| 波密县| 青铜峡市| 太保市| 新乡县| 平乡县| 黄冈市| 礼泉县| 大余县| 辽中县| 南京市| 永宁县| 云龙县| 确山县| 淮北市| 霸州市| 曲周县| 佛山市| 兴化市| 桦南县| 南和县| 宜良县| 西峡县| 县级市| 南皮县| 拜城县| 丽江市|