changeImg(){
uni.chooseImage({
count: 1, //默认9
success:(res) => {
// console.log('filePath',res.tempFilePaths[0])
var fileUrl = res.tempFilePaths[0]
uni.uploadFile({
url:this.$store.state.baseUrl+ '/upload/image',
filePath: fileUrl,
name: 'file',
success:(ress) => {
console.log('ress',JSON.parse(ress.data));
let it =JSON.parse(ress.data);
console.log(it.data);//图片路径
// 后续处理
this.$u.api.updAvatar({avatar:it.data}).then(res =>{
if(res.code == 200){
this.avatar = it.data
}
})
},
})
}
});
},
uni-app上传图片套用模板
最新推荐文章于 2024-06-13 16:09:23 发布