element 官網上寫的很清楚
toggleRowSelection | 用於多選表格,切換某一行的選中狀態,如果使用了第二個參數,則是設置這一行選中與否(selected 為 true 則選中) | row, selected |
然而,我從后端獲取到數據后渲染table后發現,自己設置的默認並沒有被勾選上列如 :this.$refs.multipleTable.toggleRowSelection(this.$refs.multipleTable.data[0],true);
這個時候我們可以使用 $nextTick (下面代碼是默認選中第一個)
that.$nextTick(function () {
this.$refs.multipleTable.toggleRowSelection(
this.$refs.multipleTable.data[0],true);
})
原因是$nextTick 是在下次 DOM 更新循環結束之后執行延遲回調,在修改數據之后使用 $nextTick,則可以在回調中獲取更新后的 DOM