我们在工作中有时候后台查出来的一些数据是int类型,但是呢,渲染在页面上就不能单调的显示整数了,如何转换呢?
因为项目用到的是Vue+element-ui,所以就贴一下Vue+element-ui的转化方法,其实代码都大差不差,也很简单。代码如下:
<el-table-column label="状态" align="center" min-width="120">
    <template slot-scope="scope">
          <span v-if="scope.row.status(status代表你返回的数据的字段名) == 0">草稿</span>
          <span v-if="scope.row.status == 1">发布</span>
          <span v-if="scope.row.status == 2">撤销</span>
    </template>
</el-table-column>
(需要注意的是你要清楚自己需要转换哪个字段)
Logo

前往低代码交流专区

更多推荐