uni-app上传图片遇到TypeError: e.split is not a function at view.umd.min.js:1
success:function(res){
that.user_photo=res.tempFilePaths;//报错
}
改为
success:function(res){
that.user_photo=res.tempFilePaths[0];
}
原因,通过
console.log(JSON.stringify(res.tempFilePaths));
可知
16:31:14.617 ["_doc/uniapp_temp_1587198502520/compressed/1587198670833.jpeg"] at pages\my\user-set-info.vue:81
res.tempFilePaths为数组,所以当上传一张图片时,取得图片临时地址为res.tempFilePaths[0];