cissy798
cissy798
  • 发布:2019-09-19 14:38
  • 更新:2019-09-19 14:38
  • 阅读:695

同步执行的问题,请教各位大神

分类:uni-app
upfile:function() {  
            //发送反馈  
            var newItems = [];  
            const storage = uni.getStorageSync('setUserData');  
            for (var i = 0; i < this.imageList.length; i++) {  
                uni.uploadFile({  
                    url: '/upload',  
                    header: {  
                        Authorization: storage.accesstoken  
                    },  
                    filePath: this.imageList[i],  
                    name: 'image' + i,  
                    success: res => {  
                    },  
                    fail: res => {  
                        console.log(res);  
                    },  
                    complete: res => {  
                        if (res.statusCode === 200) {  
                            newItems.push(JSON.parse(res.data).data);  
                        }  
                    }  
                });  
            }  
            return newItems;  
        },  
        send(){  

            let urlItems = this.upfile();  
            console.log(urlItems);  
        }

请问大大们,为什么执行send的时候没等图片上传完返回图片存储地址,就执行console了,是我哪里写错了吗

另外同步的代码怎么写呢?我没看懂。新人小白

2019-09-19 14:38 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复