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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM