Ant Design Vue中Table的选中详解

<template>
    <a-table
        :columns="columns"
        :data-source="data"
        :row-selection="rowSelection"
    />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
const columns = [
    {
        title: 'Name',dataIndex: 'name',key: 'name',},{
        title: 'Age',dataIndex: 'age',key: 'age',width: '12%',{
        title: 'Address',dataIndex: 'address',width: '30%',key: 'address',]

const data = [
    {
        key: 1,name: 'John Brown sr.',age: 60,address: 'New York No. 1 Lake Park',{
        key: 2,name: 'Joe Black',age: 32,address: 'Sidney No. 1 Lake Park',]

const rowSelection = {
    // 选中项发生变化时的回调;根据这个函数就可以获取用户勾选的哪一个值
    onChange: (selectedRowKeys: (string | number)[],selectedRows: []) => {
        console.log(
            `选中的值: ${selectedRowKeys}`,'selectedRows: ',selectedRows
        )
    },// 户手动选择/取消选择某列的回调
    onSelect: (record: [],selected: boolean,selectedRows: []) => {
        console.log(
            '  户手动选择/取消选择某列的回调 ',record,selected,// 用户手动选择/取消选择所有列的回调
    onSelectAll: (selected: boolean,selectedRows: [],changeRows: []) => {
        console.log(
            '  用户手动选择/取消选择所有列的回调  ',selectedRows,changeRows
        )
    },}

export default defineComponent({
    setup() {
        return {
            data,columns,rowSelection,}
    },})
</script>

相关文章

过滤器:就是筛选filters: [ { text: '全部', v...
好处: 就是可以实现 响应式 拉伸行(row) 列(col)col要直接在...
创好vue 项目npm 下载antnpm i --save ant-design-vue@next完...
外面套个from 标签就好了。
antDesign表单函数配置分析用getFieldDecorator包起来的高阶...
之前在vue页面中引入axios使用,本篇在mainjs中引入1、mainj...