vue中formatter方法的使用

两种方式都可以,主要是后台传过来数据,有的是字母比如,NY之类的,N代表好,Y代表不好,我们在页面显示时候要显示文字,这个时候用

<el-table-column
                  prop="createTime"
                  label="创建时间"
                  :formatter="dateFormat">

然后js

dateFormat(row, column, cellValue, index){
                const daterc = row[column.property]
                if(daterc!=null){
                    const timeFormat=  daterc.split("T")[0];
                    return timeFormat;
                }
            },

第二种方式

<el-table-column
                  prop="isLine"
                  label="是否在线">
                  <template slot-scope="scope">
                      <span v-if="scope.row.isLine == 'N'" style="color:red">不在线</span>
                      <span v-else>在线</span>
                  </template>
                </el-table-column>

 

posted @ 2020-12-24 14:58  武向前  阅读(10043)  评论(0编辑  收藏  举报