el-tree 懒加载点击某一行展开

801 阅读1分钟

<el-table
  :key="tableKey"
  :data="tableData"
  class="drag"
  ref="menuTable"
  v-loading="loading"
  row-key="id"
  lazy
  :load="load"
  :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  :max-height="getTableHeight()"
  @row-click="handleRowClick"
>
</el-table>

// table点击展开
handleRowClick(row) {
  this.$refs.menuTable.store.loadOrToggle(row)
  if (!row.children || row.children.length === 0) return
  // 如果不是懒加载 用这一行就行
  this.$refs.menuTable.toggleRowExpansion(row)
},