1. 程式人生 > >定一條資料用: => slot-scope屬性,再顯示對應的資料

定一條資料用: => slot-scope屬性,再顯示對應的資料

通過  Scoped slot 可以獲取到 row, column, $index 和 store(table 內部的狀態管理)的資料: {{ scope.row}} =>獲取整行的資料 {{scope.$index}} => 行的下標 使用: <el-table <el-table-column <template slot-scope="scope">

{{ scope.row.userSex === 1 ? "男" : "女" }} </template>

/el-table-column> /el-table> 2.只繫結一個數據,例如:sex:'女' <ui-table-column prop="userSex" label="性別" width="80px" :formatte r="getSexType" show-overflow-tooltip> </ui-table-column> 再通過formatter屬性來格式化資料(定義沒有資料的顯示內容)如下: getSexType(row, column) { return sexType(row[column.property]) } row[column.property] => 獲取表格裡資料 sexType => 定義的公共方法(邏輯)