elementUI怎么使用过滤器?

如果是HTML渲染的话,我知道怎么去使用,但项目需要用了elementUI框架,好多东西都封装好了。

//过滤器
filters: {
    statusFormat: function(value) {
        if( value == 1){
            return '正常';
        }
        else if( value == 2){
            return '锁定';
        }
        else if( value == 0){
            return '审核中';
        }
    }
}

//不用elementUI
<tr v-for="(item,index) in infoData">
    <td>{{item.status|statusFormat}}</td>
</tr>

//用了elementUI
<el-table-column prop="status" label="STATUS" sortable></el-table-column> 

这叫我怎么用啊,全是一些封装好的东西。

阅读 3.3k
2 个回答
<el-table-column prop="status" label="STATUS" sortable>
    <template slot-scope="scope">{{ scope.row.value==1?'正常':'锁定' }}</template>
</el-table-column> 
// template
<el-table-column prop="status" label="STATUS" sortable :formatter="format"></el-table-column> 

// js
methods: {
    format (row) {
        let value = row.status
        if( value == 1){
            return '正常';
        }
        else if( value == 2){
            return '锁定';
        }
        else if( value == 0){
            return '审核中';
        }
    }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题