vxe-table 實現表格單選資料

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

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

官網:https://vxetable.cn

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

<script>
export default {
  data () {
    const gridOptions = {
      border: true,
      height: 300,
      showOverflow: true,
      radioConfig: {
        labelField: 'name',
        highlight: true
      },
      columns: [
        { type: 'radio', 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

相關文章