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. 微信chooseImage接口部分机型选择图片后莫名其妙的跳转其他页面2. javascript - 在静态页面上用load 引入的页面文件问题?3. HTML5禁止img预览该怎么解决?4. css3 - 微信前端页面遇到的transition过渡动画的bug5. docker start -a dockername 老是卡住,什么情况?6. c++ - win764位环境下,我用GCC为什么指针占8个字节,而long是4个字节?7. javascript - babel转码目标文件下有除了.js的其他文件,转码后只有.js文件。8. ueditor上传服务器提示后端配置项没有正常加载,求助!!!!!9. web前端是做什么的10. javascript - 关于微信公众号开发的一个trouble!