ElementUI常用筆記

1. Table表格從後臺接收數據並個性化展示

方法一:添加格式化函數
<el-table-column prop="status" label="流程狀態" min-width="70" :formatter="stateFormat">:formatter="stateFormat"
然後寫函數方法

        stateFormat(row, column) {
            if (row.status === 0) {
                return '正常'
            } else if (row.status === 1) {
                return '暫停'
            }
        },

方法二:插槽

 <el-table-column prop="status" label="流程狀態" min-width="70">
                        <template slot-scope="scope">
                            <span v-if="scope.row.status=='0'">正常</span>
                            <span v-if="scope.row.status=='1'" 	    style="color:red;">暫停</span>
                            <span v-if="scope.row.status=='2'">終止</span>
                        </template>
                    </el-table-column>

效果:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章