javascript - promise.then();括號里面函數不執行。
問題描述
var promise = new Promise(function(resolve,rejeact){var item=res.data.resultData;if(item.c1_platform_price==''){ document.querySelector('.Js_c1Item').style.display='none';}if(item.c2_platform_price==''){ document.querySelector('.Js_c2Item').style.display='none';}var banPhoto=document.querySelector('.Js_banPhoto');banPhoto.src=` img/place/${res.data.resultData.drivingSchoolImg}`;page.c1_platform_price = item.c1_platform_price;page.c2_platform_price = item.c2_platform_price;page.desc=''; if(!page.c1_platform_price==''){ page.desc+=`C1平臺價:${page.c1_platform_price}`;}if(!page.c2_platform_price==''){ page.desc+=`C2平臺價:${page.c2_platform_price}`;}page.eventName = item.eventName;var _html='<span>招收范圍:</span>';schoolName.innerHTML=page.eventName;address.innerHTML=item.drvingSchoolAddress;item.eventAreaData.forEach(function(data){ _html+=`<span class='item'>${data.area}</span>`;})range.innerHTML=_html;c1_platform_price.innerHTML=page.c1_platform_price;c1_retail_price.innerHTML=item.c1_retail_price;c2_platform_price.innerHTML=page.c2_platform_price;c2_retail_price.innerHTML=item.c2_retail_price;c1_exam_price.innerHTML=item.c1_exam_price;c2_exam_price.innerHTML=item.c2_exam_pricecustomerName.innerHTML=item.customerName;mobile.innerHTML=item.mobile;page.drivingSchoolLog = item.drivingSchoolLog;document.querySelector('.Js_qrcodeName').src=`../FileAllinOne/marketingQrCode/${page.customerId}/${page.eventId}/${item.qrcodeName}`;return promise;});promise.then(function(){ console.log(’Resolved’); page.complete();});
問題解答
回答1:promise函數沒有resolve,正確的寫法參照下面的代碼
var promise = new Promise((resolve, reject) => {resolve(1)});promise.then((data) => { console.log(data)});
相關文章:
1. 運行python程序時出現“應用程序發生異常”的內存錯誤?2. 小白學python的問題 關于%d和%s的區別3. macos - 無法source activate python274. css - 關于background-position百分比的問題?5. github - 求助大神啊,win10 git clone error,折騰了幾天都不行,以前原本好好的,突然就這樣了6. javascript - npm run build后調用api返回index.html7. css3 - css怎么做出這樣的效果?8. html - vue里面:src在IE(9-11)下不顯示圖片9. javascript - node得到req不能得到boolean10. android - 如何實現QQ pad 點擊右側輸入框,只頂右側的布局,左側布局不動

網公網安備