promise链式调用

that.test1().then(res => {
    return that.test2(res);}).then(res => {
    console.log(res);
})

test1(){
    var that = this;
    var p = new Promise((resolve,reject) => {
        resolve(‘hello ‘);
    })
    return p;
},
test2(params){
    var that = this;
    var p = new Promise((resolve, reject) => {
        resolve(`${params}world!`);
    })
    return p;
},

相关推荐