uni-app开发遇到的坑

上传图片

注意:小程序时必须要写header:{“Content-Type”: “multipart/form-data”}, h5是必须省略

	chooseImg(){
				let that = this
				uni.chooseImage({
				  	count: 1,
				    success: (res)=> {
						const tempFilePaths = res.tempFilePaths[0]; 
						uni.uploadFile({
							url:`https://test-mall.lhsc99.cn/index.php`, 
							filePath: tempFilePaths, // uni.chooseImage函数调用后获取的本地文件路劲
							name:'file', //后端通过'file'获取上传的文件对象
							formData:{
								access_id:uni.getStorageSync("access_id"),//
								store_id:1,
								store_type:2,
								module:'app',
								action:'user',
								app:'uploadImg',
								type:'comments',
								file:tempFilePaths
							},
							// #ifdef MP-WEIXIN
							header:{"Content-Type": "multipart/form-data"},
							//#endif
							success:(res) => {
								
							}
						});
				    }
				});
			}

uni-app h5 端的ios图片不能加载问题

uni-app h5端 ios只能加载https的图片 (坑坑坑)

uni-app 使用deep 穿透微信小程序生效 h5无作用

需要在methods同级下加一个 :
options: { styleIsolation: ‘shared’ },

uni-app post请求如何传递数组 参数

在开发中我们接口上传图片是post请求 无法传递一个数组 解决方法如下

我们可以把数据转换成字符串 然后拼接到请求地址后后面
拼接字符串格式:image[]=arr[0]&image[]=arr[1]

imgUrlClick(imgArr){
	 return '?images[]='+imgArr.join('&images[]=')
},
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值