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