uniapp上传base64格式图片给后台

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

你可能感兴趣的:(uni-app,微信小程序,vue,js)