antDesignVue 表格默认禁止选中或默认选中
<template><a-table:columns="columns":dataSource="data"rowKey="id":loading="loading":pagination="pagination":rowSelection="rowSelection"...
·
<template>
<a-table
:columns="columns"
:dataSource="data"
rowKey="id"
:loading="loading"
:pagination="pagination"
:rowSelection="rowSelection"
>
</a-table>
</template>
<script>
export default {
computed: {
rowSelection() {
const _this = this
const { selectedRowKeys } = this;
return {
selectedRowKeys,
onChange: (selectedRowKeys) => {
this.selectedRowKeys = selectedRowKeys;
if (this.selectedRowKeys.length) {
this.disabled = false;
} else {
this.disabled = true;
}
},
getCheckboxProps: record => ({
props: {
// 全部默认禁止选中
disabled: true,
// 某几项默认禁止选中(R: 当state等于1时)
// disabled: record.state == 1,
// 某几项默认选中(R: 当state等于1时)
defaultChecked: record.state == 1,
},
}),
};
},
}
}
</script>
更多推荐
已为社区贡献3条内容
所有评论(0)