【发布时间】:2019-11-28 11:26:34
【问题描述】:
state = { driverid: '', history: [{}] }
constructor(props) {
super(props);
}
componentDidMount(){
this.setState({ driverid: this.props.navigation.getParam('driverid', 'NO-ID') },
() => {
const GameScore = Parse.Object.extend("Booking");
const query = new Parse.Query(GameScore);
query.equalTo("driverid", this.state.driverid);
query.find().then(function (results) {
console.log("Successfully retrieved " + results.length + " scores.");
for (var i = 0; i <= results.length; i++) {
this.state.history.push(results.get(results[i]))
}
console.log(this.state.history)
});
});
}
执行时我无法将push元素放入数组中,上面的程序给出以下错误
WARN 可能的未处理 Promise Rejection (id: 0): TypeError: undefined 不是对象(评估 'this.history.push')
【问题讨论】:
标签: reactjs