微信原生小程序转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 = falset.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);}});}