TypeError: undefined is not an object (evaluating 'o.type.name')

本文解决uni-app在小程序和APP端启动时出现白屏的问题,通过真机调试定位到错误文件并修复。强调了在编写组件时声明属性类型的必要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

uni-app启动报错,造成白屏,H5端正常,小程序和APP报错如下:

reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->TypeError: undefined is not an object (evaluating 'o.type.name')
getTemplateInfo== template md5 d4747f701467e54e45cbae7bc3c29e61 length 17231462 base64 md5 1HR/cBRn5U5Fy657w8KeYQ== response header {"templateSourceBase64MD5":["1HR/cBRn5U5Fy657w8KeYQ=="],"templateSourceMD5":["d4747f701467e54e45cbae7bc3c29e61"]}

原因:

解决方式:

首先我们需要定位到错误在哪里,直接运行到HbuilderX运行到真机无法定位到问题出自哪一个文件,我们需要点击控制台的debug图标,如下:

打开真机调试视图之后,看到如下报错信息就能够定位到问题文件:

找到对应的文件

保存,问题解决。

uni-app H5端容错率较高,APP端和小程序端语法更严格,报的错误很难定位到问题点,写组件的时候一定要注意给属性声明类型。

ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[19], "react-native-thermal-receipt-printer").default.Printer') LOG 获取内部存储ApiservBaseurl成功!Value= null INFO 请求服务:https://momappapi.xiolift.com/smapi/dibang/getDibangConfig 参数{} LOG 获取内部存储ApiservBaseurl成功!Value= null INFO 请求服务:https://momappapi.xiolift.com/smapi/wasteMaterial/listTrussOutHistory 参数{"code":"2025-08-04"} LOG {"code": 122, "list": [{"code": "1001", "id": null, "name": "三期东", "redUrl": "http://10.19.0.58:39320/iotgateway/read?ids=sanqidibang251.S7200.%E5%85%89%E7%94%B51", "rtspUrl": "rtsp://linjun:Xiolift123@10.19.94.22:554/Streaming/Channels/101", "topic": "dibang/100001/weight"}, {"code": "2001", "id": null, "name": "一期南", "redUrl": "http://10.19.0.58:39320/iotgateway/read?ids=yiqidiban244.S7200.%E5%85%89%E7%94%B51", "rtspUrl": "rtsp://linjun:Xiolift123@10.19.30.23:554/Streaming/Channels/101", "topic": "dibang/100003/weight"}, {"code": "2002", "id": null, "name": "二期北", "redUrl": null, "rtspUrl": "rtsp://linjun:Xiolift123@10.19.31.135:554/Streaming/Channels/101", "topic": "dibang/100002/weight"}, {"code": "1002", "id": null, "name": " 三期西", "redUrl": null, "rtspUrl": null, "topic": "dibang/100004/weight"}, {"code": "1005", "id": null, "name": null, "redUrl": null, "rtspUrl": "rtsp://linjun:Xiolift123@10.19.31.230:554/Streaming/Channels/101", "topic": "dibang/100005/weight"}], "message": "成功!", "total": null, "type": null} LOG res {"code": 1, "list": [], "message": "成功!", "total": null, "type": null} LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/loginfo.txt' LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/logexception.txt' LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/loginfo.txt' LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/logexception.txt' ERROR TypeError: undefined is not an object (evaluating '_reactNativeThermalReceiptPrinter.default.Printer') LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/loginfo.txt' LOG ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/xioliftmes/logexception.txt' ERROR TypeError: undefined is not an object (evaluating '_reactNativeThermalReceiptPrinter.default.Printer') 在使用 import ThermalPrinter from 'react-native-thermal-receipt-printer'; const { Printer, PrinterTypes } = ThermalPrinter;这样引入的时候会有以上的报错
最新发布
08-05
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值