(vue)AntD表格操作完成后去掉勾选

(vue)AntD表格操作完成后去掉勾选

<template>
  <a-table :row-selection="rowSelection" :columns="columns" :data-source="data" />
</template>
export default { 
data () {
	return:{ 
      	 selectedRowKeys:[], // 批量选中的key
	}
}
computed:{
	 rowSelection() {
	 	const { selectedRowKeys } = this;
      	return {
      		selectedRowKeys, // 一定要加上这一行代码,清除才会有作用
        	onChange: (selectedRowKeys, selectedRows) => { 
         	 	this.selectedRowKeys = selectedRowKeys
	            selectedRows.forEach((element) => {
	              this.id.push(element.id)
	            })
      		};
    	},
	},
	methods:{
		clearData () {
			this.selectedRowKeys = [] // 调用这个方法就有效果了
		}
	}
}

解决参考:https://www.pudn.com/news/6246781962b5053d3c7aa94a.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用 Ant Design Vue表格树组件,您需要先安装和导入 Table 和 TreeSelect 组件。 在表格中,您需要使用 `customExpandIcon` 属性来自定义展开/折叠图标,并使用 `customRow` 属性来自定义行的渲染。 以下是一个示例代码: ```vue <template> <a-table :columns="columns" :data-source="data" :custom-row="customRow" :custom-expand-icon="customExpandIcon"> <template slot="name" slot-scope="{ record }"> {{ record.name }} </template> </a-table> </template> <script> import { Table, TreeSelect } from 'ant-design-vue'; export default { components: { Table, TreeSelect, }, data() { return { columns: [ { title: 'Name', dataIndex: 'name', key: 'name', scopedSlots: { customRender: 'name' }, }, { title: 'Age', dataIndex: 'age', key: 'age', }, { title: 'Address', dataIndex: 'address', key: 'address', }, ], data: [ { key: '1', name: 'Parent 1', age: 30, address: 'New York No. 1 Lake Park', children: [ { key: '1-1', name: 'Child 1-1', age: 12, address: 'New York No. 2 Lake Park', }, { key: '1-2', name: 'Child 1-2', age: 13, address: 'New York No. 3 Lake Park', }, ], }, { key: '2', name: 'Parent 2', age: 32, address: 'London No. 1 Lake Park', children: [ { key: '2-1', name: 'Child 2-1', age: 11, address: 'London No. 2 Lake Park', }, { key: '2-2', name: 'Child 2-2', age: 16, address: 'London No. 3 Lake Park', }, ], }, ], }; }, methods: { customExpandIcon({ record, onExpand }) { if (record.children) { return ( <a onClick={onExpand}> {record._expanded ? <a-icon type="minus-square" /> : <a-icon type="plus-square" />} </a> ); } return null; }, customRow(record, index, indent, expanded) { return { class: `custom-row-${record.key}`, on: { click: () => { console.log(record); }, }, }; }, }, }; </script> ``` 在上面的代码中,您可以看到我们自定义了展开/折叠图标和行的渲染,以及使用了插槽 `scopedSlots` 来渲染名称列。您还可以根据您的需求来添加其他自定义的组件或插槽。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值