<Input onInput={this.inputHandler.bind(this)}/>
this.state = { current: 0, tabObj: {title: ‘未使用‘,text:‘已使用‘}, dataList: [ {name: ‘jack‘, age: 28}, {name: ‘rose‘, age: 18} ] } inputHandler(e) { this.setState((preState) => { //修改基本类型数据 preState.current = e.detail.value; //修改某一对象属性 preState.tabObj.title = e.detail.value; //修改整个对象 preState.tabObj = {title:e.detail.value,text:‘xxx‘} //修改某一数组对象属性 preState.dataList[0].name = e.detail.value; //修改某一数组对象全部属性 preState.dataList[0] = { name: e.detail.value, age: 9 }; //修改整个数组 preState.dataList = [ { name: e.detail.value, age: 99 }, { name: e.detail.value, age: 88 }, ]; }, () => { console.log(this.state.current); console.log(this.state.dataList); console.log(this.state.dataList); }) }