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