当前位置:首页 > 前端 > 正文内容

Ant Design table自定义复选框的默认不可选状态

Z先生5年前 (2021-02-23)前端894

官网上的getCheckboxProps中的disabled的值是record.name==="XXX",我在用的过程中肯定是一个list,然后我就想用函数返回true或false,虽然功能不影响,但是打印台一直报错,提示disabled支持布尔,不支持函数。后来才找到办法解决,下面直接上代码

table定义

<a-table
    :loading="loading"
    rowKey="userId"
    :rowSelection="{
        selectedRowKeys: selectedRowKeys,
        onChange: onSelectChange,
        onSelect: selectEvent,
        onSelectAll: onSelectAll,
        getCheckboxProps: getCheckboxProps
     }"
     :columns="column"
     :dataSource="tableList"
     :pagination="false"
/>


关键在于:getCheckboxProps

getCheckboxProps(record) {
      return ({
        props: {
              disabled: record.isaudit==1
            }
      })
    },





标签: vueantd
分享给朋友:

相关文章

js关于this的小技巧

这段时间,vue写的多了,习惯了es6的方式写函数,但是这种写法很容易导致this失效,比如刚刚发布的vue深度监听的问题,用了es6的写法,this就没法用,换回传统写法就可以了。// es6写法,...

问题: - did you register the component correctly......

问题: - did you register the component correctly......

问题:无法使用tree组件提示 Unknown custom element:<a-tree> - did you register the component correctly? Fo...

npm锁定依赖包版本

在某些特殊时候,npm需要锁定依赖包的版本,其方法有2种 安装时后面代参数-E修改package.json文件,去掉版本号前面的^ 常用命令: npm install --save-dev...

elemeui表格中点击修改最优雅的方式

需求表格中,某一列需要点击修改。并且能拦截回车事件。 解决方案vue代码<el-table ref="menuTable" …… @cell-click="cli...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。
请先 登录 再评论,若不是会员请先 注册