微信原生小程序转uniapp过程及错误总结

https://ask.dcloud.net.cn/article/35786 此文章尤为重要,可以使用辅助工具

1、this.setData

复制代码
源代码:
this.setData({
      dateTime: obj.dateTime,
});

需更换为
this.dateTime =  obj.dateTime

2、cookie问题

在此文章有解释

https://blog.csdn.net/ni15534789894/article/details/141607435?spm=1011.2415.3001.5331

3、区分小程序及uniapp

复制代码
if(uni.getSystemInfoSync().platform == 'devtools')
uni.getSystemInfoSync().platform为devtools是小程序

4、接口请求不成功

一定要查看url以及filePath都不为空才可以
复制代码
if(uni.getSystemInfoSync().platform == 'devtools'){
		console.log(999)
		const uploadFilePross = wx.uploadFile({
		    // url: 'http://10.64.11.212:8088/receive/uploadAudio',
		    url: 'https://qrcode.sprixin.com:51080/receive/uploadAudio',
		    methid: 'POST',
		    // 可用可不用
		    formData: {
		        username: username
		    },
		    filePath: upVideoArr,
		    name: 'file',
		    // 服务器定义key字段名称
		    header: app.globalData.header,
		    success: function (res) {
				console.log(res,'888')
		        var data = JSON.parse(res.data);
				console.log(data,'999')
		        if (data.success) {
		            // if (index == upVideoArr.length - 1) {
		                uni.showModal({
		                    title: '提示',
		                    content: '上传成功',
		                    showCancel: false,
		                    complete: (res) => {
		                        if (res.confirm) {
		                            t.disabled = false
		                            t.upVideoArr = []
		                            t.upFilesProgress = false
		                        }
		                    }
		                });
		            // }
					 // else {
		    //             index++;
		    //             data.index = index;
		    //             // uploadFiles(username, t, data, progress, success);
		    //         }
		        } else {
		        }
		    }
		});
		uploadFilePross.onProgressUpdate((res) => {
		    res['index'] = index;
		    if (typeof progress == 'function') {
		        progress(res);
		    }
		});
	}
相关推荐
绝缘体11 天前
如何使用外卖霸王餐api接口?
大数据·搜索引擎·微信·pygame
局外人LZ1 天前
Uniapp脚手架项目搭建,uniapp+vue3+uView pro+vite+pinia+sass
前端·uni-app·sass
新时代牛马2 天前
CANopen 协议详解
linux·微信
光影少年2 天前
AIGC + Taro / 小程序
小程序·aigc·taro
2501_915918412 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview
前端呆头鹅2 天前
Websocket使用方案详解(uniapp版)
websocket·网络协议·uni-app
浮桥2 天前
uniapp+h5 公众号实现分享海报绘制
uni-app·notepad++
2501_916007472 天前
没有 Mac 用户如何上架 App Store,IPA生成、证书与描述文件管理、跨平台上传
android·macos·ios·小程序·uni-app·iphone·webview
天空属于哈夫克32 天前
Go 语言实战:构建一个企微外部群“技术贴收藏夹”小程序后端
小程序·golang·企业微信
wangjun51592 天前
uniapp uni.downloadFile 偶发性下载文件失败 无响应
uni-app