el-table-column在template情況下使用formatter


<el-table-column label="Group" prop="group" align="center" :formatter="stateFormat"> 
  <template slot-scope="scope">
     <div v-if="newVersion">
      <el-tag type="primary" size="mini"> {{scope.row.group|$_groupConstConfigFilter}} </el-tag>
     </div>
     <span v-if="!newVersion" v-html="stateFormat(scope.row.group)"></span>
  </template>
</el-table-column>

重點在標紅地方,上面是html代碼。

 

下面js代碼實現formatter

stateFormat(group) {
    for (let i = 0; i < this.groups.length; i++) {
       if (group == this.groups[i].code) {
           return this.groups[i].name;
       }
    }
    return group
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM