React:react+mobx+antd,select设置全选

// 组件
import React from 'react'
import {Select, Checkbox, Divider} from 'antd'
import {observer, inject,} from 'mobx-react'
import {withRouter} from "react-router-dom";
import { runInAction} from 'mobx';

@withRouter
@inject('selectStore')
@observer
class SelectAll extends React.Component {
    state = {
        isCheckedAll: false
    }
    componentWillMount () {
        this.setState({
            isCheckedAll: this.props.isCheckedAll
        })
    }
    _onChange = (e) => {
        // 判断 是否 选中
        runInAction(() => {
            if (e.target.checked === true) { // 全选操作
            } else {// 取消全选
            }
        })
    }

    onChanges = (key) => {
        if (key.length === this.props.children.length) {
            this.props.onChange(key,true)
        } else {
            this.props.onChange(key,false)
        }
    }
    render() {
        return (
            
        )
    }
}

export default SelectAll
// 使用

    {list.map(item => (
        
    ))}

你可能感兴趣的:(React:react+mobx+antd,select设置全选)