当前位置:首页 > 前端

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

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

官网上的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
分享给朋友:

相关文章

vue踩坑记20201027

elemeui/antd等框架,再使用复选框、下拉选择框时,如果通过v-model绑定了值,那么选择时,界面不会改变。方法一:使用default-value指定默认值,@change去改变本该v-mo…

UNIAPP内容区域高度定义

代码如下height: calc(100vh - var(--window-top) - var(--window-bottom));CSS变量uni…

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…

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

需求表格中,某一列需要点击修改。并且能拦截回车事件。 解决方案vue代码 {{ row.order }} JS methods 方法```…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。