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

原创
2024/08/06 08:57
阅读数 59

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

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

报错方法

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

解决办法

替换为:Array.isArray

if (Array.isArray(dicts)) {
  
}

this.$route.query query未定义

报错方法

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

解决办法

替换成 onLoad 方法获取参数

onLoad(e) {
  const id = e.id;
  this.loadData(id);
},

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

报错方法

let list= res.rows;
this.list = [...this.list,...list];

解决办法

替换成 concat 

this.list = this.list.concat(list);

 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部