【解决】uniapp踩坑记录,真机调试 instanceof 无法判断数组类型、路由报错query未定义...

坑位,在web访问中一切正常,错误只出现在真机调试中.....

真机调试 instanceof 无法判断数组类型

报错方法

javascript 复制代码
if (dicts instanceof Array) {
   //就是进不来,uniapp真机调试中给判断为false
}

解决办法

替换为:Array.isArray

javascript 复制代码
if (Array.isArray(dicts)) {
  
}

this.$route.query query未定义

报错方法

javascript 复制代码
mounted() {
  // 获取路由参数中的Id
  const id = this.$route.query.id;
  this.loadData(id)
},

解决办法

替换成 onLoad 方法获取参数

javascript 复制代码
onLoad(e) {
  const id = e.id;
  this.loadData(id);
},

ES6的新语法扩展运算符(...)不识别

报错方法

javascript 复制代码
let list= res.rows;
this.list = [...this.list,...list];

解决办法

替换成 concat

javascript 复制代码
this.list = this.list.concat(list);
相关推荐
2501_916007471 天前
iOS 证书如何创建,从能生成到能长期使用
android·macos·ios·小程序·uni-app·cocoa·iphone
00后程序员张1 天前
AppStoreInfo.plist 在苹果上架流程中的生成方式和作用
android·小程序·https·uni-app·iphone·webview
2501_915106321 天前
iOS App 测试方法,通过 Xcode、Instruments、Safari Inspector、克魔(KeyMob)等工具
android·ios·小程序·uni-app·iphone·xcode·safari
游戏开发爱好者81 天前
对 iOS IPA 文件进行深度混淆的一种实现路径
android·ios·小程序·https·uni-app·iphone·webview
百锦再1 天前
UniApp与UniApp X:跨平台开发的范式革命与全面技术解析
服务器·ai·uni-app·k8s·core·net
Change!!1 天前
uniapp写的h5,怎么根据页面详情,设置不同的标题
前端·uni-app·标题
2501_916007471 天前
Xcode 在 iOS 上架中的定位,多工具组合
android·macos·ios·小程序·uni-app·iphone·xcode
浅箬1 天前
uniapp 打包之后出现shadow-grey.png去除
前端·uni-app
游戏开发爱好者81 天前
uni-app 项目在 iOS 上架过程中常见的问题与应对方式
android·ios·小程序·https·uni-app·iphone·webview
2501_915106322 天前
iOS 抓包工具在不同场景的实际作用
android·macos·ios·小程序·uni-app·cocoa·iphone