父组件

class Parent extends Component {
    constructor(props) {
        super(props)
        this.state = {
            list:['a','b','c','d']
        }
        this.deleteItem = this.deleteItem.bind(this)
    }
     deleteItem(index) {
        const newState = this.state.list(index,1);
        this.setState({list:newState})
    }
    render(){
        return(
            <Child
            list={this.state.list}
            deleteItem={this.deleteItem}
            />
        )
    }
}

子组件

class Child extends Component {
    render(){
        return(
             <List
            bordered
            dataSource={this.props.list}
            renderItem={(item, index) => (
              <List.Item onClick={()=>{this.props.deleteItem(index)}}>{item}</List.Item>
            )}
          />
        )
    }
}
export default Child;

————————————————
转于链接:https://blog.csdn.net/z218174...


云端的日子
66 声望1 粉丝