您好!欢迎来到聚码网

聚码网

热门搜索: 相亲小程序    搭子源码    直播系统自有商城   
  • ES7async和await方法使用问题
  • 聚码交流
  • 0 1
  • yhuxAvNbtxUM
    0000-00-00 00:00:00
  • 回帖
想利用await关键字把返回的url赋给url变量但是console.log一直打出undefineduploadImgReq方法代码如下:uploadImgReq:function(file){varnameKey=this.generateUUID();//event.target.files[0].name=nameKey;this.$http.get(this.url+'/qiniu/token',{params:{key:nameKey}}).then((response)=>{this.token=response.data.data.token;if(this.token!=null){varformData=newFormData();formData.append('file',file);formData.append('key',nameKey);formData.append('token',this.token);this.$http.post('http://upload.qiniu.com/',formData,{headers:{'Content-Type':'multipart/form-data'}}).then((response)=>{if(response.status==200){this.uploadStatus=false;this.$message({message:'上传成功',type:'success'});varimgUrl=this.qiniu+response.body.key;console.log("iamreturned")returnnewPromise(function(resolve,reject){resolve(imgUrl)})}}).catch((response)=>{})}}).catch((response)=>{})请问各位问题出在哪里了呢
最近热帖
近期热议
联系我们
Q Q:317563994
电话:400-000-000
邮箱:317563994@qq.com
时间:09:00 - 17:00