在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ antd的Table表格默認(rèn)會(huì)勾選上次勾選的,怎么清除

antd的Table表格默認(rèn)會(huì)勾選上次勾選的,怎么清除

我設(shè)置了默認(rèn)勾選13,第一次提交(132)是對(duì)的,第二次,頁(yè)面上還勾選著上次提交的,沒(méi)有按getCheckboxProps配置的渲染,然后onChange這,輸出的是上一次提交的(132)+本次默認(rèn)(13)+新勾的(45)= [1, 3, 2, 1, 3, 4, 5]
我是百思不得其解。



class User extends Interval {
    constructor(props) {
        super(props);
        this.state = {
            synCode: [],
        }
    }

    render() {
        console.log(this.state.synCode);
        const _this = this;
        const rowSelection = {
            getCheckboxProps(record) {
                return {
                    defaultChecked: record.leader === 1, // 配置默認(rèn)勾選的列
                };
            },
            onChange(selectedRowKeys) {
                console.log('新來(lái)的',selectedRowKeys);
                // console.log('原來(lái)的',_this.state.synCode);
                _this.setState({synCode: selectedRowKeys})

            },
        };
       
        return (
            <Table rowSelection={rowSelection} columns={columns} dataSource={this.state.data} />
        );
    }
}
回答
編輯回答
愛(ài)是癌

@moveStar 這個(gè)表格,我是封裝成一個(gè)組件用的,之后我給這個(gè)組件加了一個(gè)key就解決了。我看網(wǎng)上各種說(shuō)清selectedRowKeys的,沒(méi)弄明白怎么清。

2018年9月16日 11:47