【解决】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);
相关推荐
00后程序员张35 分钟前
使用Instruments工具深入分析iOS应用性能与启动时间优化
android·macos·ios·小程序·uni-app·cocoa·iphone
古韵2 小时前
小程序上传进度条,还要自己监听 onProgressUpdate 吗?
前端·javascript·uni-app
不如摸鱼去1 天前
Wot UI 2.3.0 发布:二维码组件来了,Open Wot 与 wot-starter 同步更新
前端·ui·微信小程序·前端框架·uni-app
anyup1 天前
uni-app 没有根组件?仅需几行代码实现全局 Toast 和 Modal
前端·架构·uni-app
2501_916007471 天前
Python实现HTTPS爬虫的完整指南:使用requests、BeautifulSoup、Selenium和Scrapy
爬虫·python·ios·小程序·https·uni-app·iphone
AI_AGENT_DEV_AI1 天前
原生 APP(iOS / Android)的开发与上线
uni-app
小徐_23332 天前
Wot UI 2.3.0 发布:二维码组件来了,Open Wot 与 wot-starter 同步更新
前端·微信小程序·uni-app
skiyee2 天前
🔥 oiyo & unibest = 又新又好的 uniapp 模板
前端·uni-app
结网的兔子4 天前
【前端开发】Web端迁移至 uni-app 及鸿蒙扩展方案对比
前端·uni-app·harmonyos
2501_915909064 天前
iOS 应用反调试技详解术 检测调试器的原理与防护实践
android·ios·小程序·https·uni-app·iphone·webview