鍍金池/ 問(wèn)答/HTML5  網(wǎng)絡(luò)安全  HTML/ elementUI怎么使用過(guò)濾器?

elementUI怎么使用過(guò)濾器?

如果是HTML渲染的話,我知道怎么去使用,但項(xiàng)目需要用了elementUI框架,好多東西都封裝好了。

//過(guò)濾器
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> 

這叫我怎么用啊,全是一些封裝好的東西。

回答
編輯回答
愛(ài)是癌
<el-table-column prop="status" label="STATUS" sortable>
    <template slot-scope="scope">{{ scope.row.value==1?'正常':'鎖定' }}</template>
</el-table-column> 
2018年2月12日 22:03
編輯回答
愛(ài)是癌
// 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 '審核中';
        }
    }
}
2018年6月29日 14:45