善护念兮

如何将后台传来的0/1转换成想要的字符,vue

暂时发现3个方法

按时间排序

第一个在获取的时候进行修改

this.BBBB.AAAA=this.BBBB.AAAA?'一':'零';

 

第二个利用vue自己的功能,在显示的时候替换。

        <el-table-column prop="bbbb" label="AA" show-overflow-tooltip align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bbbb == 0">零</span>
            <span v-if="scope.row.bbbb == 1">一</span>
          </template>
        </el-table-column>
     <el-table-column label="BBB" align="center" min-width="120">
        <template slot-scope="scope">
          <span v-if="scope.row.aaa == 2">一</span>
          <span v-else-if="scope.row.aaa== 3">二</span>
          <span v-else="scope.row.aaa == 4">三</span>
        </template>
      </el-table-column> 

 

第三个,利用map,在显示的时候替换

const map = {boolean:{0:'零',1:'一',2:'二'}}
<div>{{map.boolean[item.id]}}</div>

 

posted on 2020-09-07 13:34  善护念兮  阅读(1221)  评论(0编辑  收藏  举报

导航