📅  最后修改于: 2022-03-11 15:03:03.892000             🧑  作者: Mango
componentWillMount() {
var promise = new Promise( (resolve, reject) => {
let name = 'Paul'
if (name === 'Paul') {
resolve("Promise resolved successfully");
}
else {
reject(Error("Promise rejected"));
}
});
let obj = {newName: ''};
promise.then( result => {
this.setState({name: result});
}, function(error) {
this.setState({name: error});
});
}