鍍金池/ 問答/HTML5  HTML/ 初學(xué)者用vue渲染表格時(shí)遇到的問題

初學(xué)者用vue渲染表格時(shí)遇到的問題

clipboard.png

這些數(shù)據(jù)都是后臺(tái)傳過來的

STATUS 為0表示為審核中
STATUS 為1表示為正常
STATUS 為2表示為鎖定狀態(tài)

但我現(xiàn)在不知道該如何改為對(duì)于的中文,該怎么弄呀?

<tr v-for="(item,index) in infoData">
    <td>{{index+1}}</td>
    <td>{{item.name}}</td>
    <td>{{item.email}}</td>
    <td>{{item.roleName}}</td>
    <th>{{item.status}}</th>
</tr>

回答
編輯回答
傲嬌范

過濾器 — Vue.js

使用過濾器即可

2017年3月6日 08:55
編輯回答
傲寒

全局的filter,可用于所有組件

{{ scope.row.paragraph | time}}

Vue.filter('time',function (params) {
     params = params ? params.slice(0,[10]):params
    return params
})
2018年1月23日 02:50
編輯回答
青裙

寫一個(gè)map

<tr v-for="(item,index) in infoData">
    <th>{{statusMap[item.status]}}</th>
</tr>

data(){
    return {
        statusMap:{
            0:"審核中",
            1:"正常",
            2:"鎖定"
        }
    }
}
2017年6月30日 11:50
編輯回答
朕略萌
2017年5月29日 13:51
編輯回答
不討喜
<th>{{item.status|statusFormat}}</th>
filters: {
    statusFormat: function(value) {
      return value === 0 ? '審核' : value === 1 ? '正常' : '鎖定'
    }
  }
2017年7月22日 03:53