vxe-table 使用表格多選資料、核取方塊多選

可不简单發表於2024-11-28

在 vxe-table 啟用列多選功能,透過引數 column.type = 'checkbox' 設定型別為多選型別就可以了。

官網:https://vxetable.cn

<template>
  <div>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script>
export default {
  data () {
    const gridOptions = {
      border: true,
      height: 500,
      showOverflow: true,
      rowConfig: {
        isHover: true
      },
      checkboxConfig: {
        labelField: 'name',
        highlight: true
      },
      columns: [
        { type: 'checkbox', title: 'Name', width: 300 },
        { field: 'id', title: 'ID' },
        { field: 'age', title: 'Age' },
        { field: 'address', title: 'Address' }
      ],
      data: [
        { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
        { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
        { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
        { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 23, address: 'test abc' },
        { id: 10005, name: 'Test5', role: 'Develop', sex: 'Women', age: 30, address: 'Shanghai' }
      ]
    }

    return {
      gridOptions
    }
  }
}
</script>

https://gitee.com/xuliangzhan/vxe-table

相關文章