data(){
return {
imgList: [],
}
},
methods:{
ChooseImage() {
var that = this;
let count = 1;//默认上传的图片数量
uni.chooseImage({
count: count, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
if(that.imgList.length < count){
for(var i = 0; i < res.tempFilePaths.length; i ++){
that.urlToBase64(res.tempFilePaths[i]).then(res=>{
that.imgList = that.imgList.concat(res)
})
}
}else {
that.imgList = []//设置为空数组
for(var i = 0; i < res.tempFilePaths
uniapp上传base64格式图片给后台
最新推荐文章于 2024-05-14 02:44:38 发布