鍍金池/ 問答/Linux  HTML/ Promise調(diào)用then()出錯(cuò)

Promise調(diào)用then()出錯(cuò)

Vue的項(xiàng)目里

let __this = this;

let pro = function () {
    return new Promise((resolve, reject) => {
        let urlGetCarList = domain + '/app/carStatusList.action';

        __this.$http.get(urlGetCarList, {
            params: {
                'dealerId': 'de590792498f11e7ae8200163e003dce',
                'beginRow': '0',
                'status': '0',
                'isShelves': '1'
            }
        }).then(response => {
            let listArr = response.body.object;
            resolve(listArr.dataList[1].oldCarId);
        });

    });
}



pro.then((id) => {
    console.log(id);
})

圖片描述

listArr.dataList[1].oldCarId打印的確是獲取到的,打印Promise也是有的。
could you please help me, thank you.

回答
編輯回答
浪蕩不羈

pro()才是返回promise,pro是函數(shù),是函數(shù),是函數(shù)!

2017年6月11日 07:24
編輯回答
做不到

可能是你的this指向不正確吧

2017年8月7日 20:35
編輯回答
黑與白
pro().then((id) => {
    console.log(id);
})
2018年1月3日 03:33