幕布斯7119047
2018-08-14 10:09:24
reactjs 在點(diǎn)擊分頁(yè)的時(shí)候,改變 state 報(bào)錯(cuò)TypeError: _this2.setState is not a function(…)下面是 代碼GetApiData(index){
let pageid = index;
let gitusername = this.state.gitusername;
let gitreponame = this.state.gitreponame;
let endApiUrl = '/api/getissues?gitusername='+ gitusername +'&gitreponame='+ gitreponame +'&pageid='+pageid;
fetch(endApiUrl)
.then((response) => { return response.json();
})
.then((obj) => { // 只要有以下這句話就會(huì)報(bào)錯(cuò) 走 `catch` this.setState({
data: obj
});
})
.catch((ex) => { console.log(ex);
});
}
onChange(index){ this.setState = {
pageid:index,
}
this.GetApiData(index);
}
1 回答

有只小跳蛙
TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊
添加回答
舉報(bào)
0/150
提交
取消