var promise = new Promise((resolve, reject) => { if (操作成功) { resolve(value) } else { reject(error) } }) promise.then(function (value) { // success
console.log(value);
}).catch(function (error) { // failure
console.log(error);
})
var promise = new Promise((resolve, reject) => { if (操作成功) { resolve(value) } else { reject(error) } }) promise.then(function (value) { // success
console.log(value);
}).catch(function (error) { // failure
console.log(error);
})