3***@qq.com
3***@qq.com
  • 发布:2023-01-18 12:17
  • 更新:2023-04-07 17:09
  • 阅读:1758

【报Bug】微信小程序打包后无法启动

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win7

HBuilderX类型: 正式

HBuilderX版本号: 3.6.18

第三方开发者工具版本号: 1.05.2204250

基础库版本号: 2.16.0

项目创建方式: HBuilderX

示例代码:

直接新建默认模板打包即可复现

操作步骤:

直接新建默认模板打包即可复现

预期结果:

可以正常进入小程序界面

实际结果:

界面空白,控制台报错

bug描述:

今天更新后出现的
运行到微信开发者工具没有问题
但是打包后启动就报错。
经测试发现,基础库在2.16.0及之下的会报错,之上的不会。

VM89:9 app.js错误:
TypeError: Cannot read property 'wx' of undefined
at Object.bc2e (VM68 vendor.js:7755)
at s (VM64 runtime.js:76)
at Object.d (VM57 main.js:94)
at s (VM64 runtime.js:76)
at n (VM64 runtime.js:54)
at Array.t [as push] (VM64 runtime.js:44)
at VM57 main.js:4
at require (VM40 WASubContext.js:11)
at r (VM40 WASubContext.js:11)
at VM84 app.js:8(env: Windows,mp,1.05.2204250; lib: 2.12.3)
(anonymous) @ VM89:9
doWhenAllScriptLoaded @ VM55:3658
scriptLoaded @ VM55:3686
(anonymous) @ VM55:3711
Promise.then (async)
(anonymous) @ VM55:3732
(anonymous) @ VM55:3736
loadScripts @ VM21 assubloader.js:1
async function (async)
loadScripts @ VM21 assubloader.js:1
loadAppResourceScripts @ VM21 assubloader.js:1
(anonymous) @ VM48 app-service.js:1
VM24 WAServiceMainContext.js:11 Uncaught FrameworkError
Cannot read property 'wx' of undefined
TypeError: Cannot read property 'wx' of undefined
at Object.bc2e (http://127.0.0.1:37670/appservice/common/vendor.js:7755:14)
at s (http://127.0.0.1:37670/appservice/common/runtime.js:76:17)
at Object.d (http://127.0.0.1:37670/appservice/common/main.js:94:19)
at s (http://127.0.0.1:37670/appservice/common/runtime.js:76:17)
at n (http://127.0.0.1:37670/appservice/common/runtime.js:54:35)
at Array.t [as push] (http://127.0.0.1:37670/appservice/common/runtime.js:44:38)
at http://127.0.0.1:37670/appservice/common/main.js:4:57
at require (http://127.0.0.1:37670/appservice/dev/WASubContext.js?t=wechat&s=1674014606052&v=2.12.3:11:2062644)
at r (http://127.0.0.1:37670/appservice/dev/WASubContext.js?t=wechat&s=1674014606052&v=2.12.3:11:2061244)
at http://127.0.0.1:37670/appservice/app.js:8:1(env: Windows,mp,1.05.2204250; lib: 2.12.3)
n @ VM24 WAServiceMainContext.js:11
c @ VM13 asdebug.js:1
window.onerror @ VM36:10
doWhenAllScriptLoaded @ VM55:3658
scriptLoaded @ VM55:3686
(anonymous) @ VM55:3711
error (async)
t.default @ VM36:10
(anonymous) @ VM36:10
n @ VM36:1
(anonymous) @ VM36:1
(anonymous) @ VM36:1
VM24 WAServiceMainContext.js:11 MiniProgramError
Cannot read property 'wx' of undefined
TypeError: Cannot read property 'wx' of undefined
at Object.bc2e (http://127.0.0.1:37670/appservice/common/vendor.js:7755:14)
at s (http://127.0.0.1:37670/appservice/common/runtime.js:76:17)
at Object.d (http://127.0.0.1:37670/appservice/common/main.js:94:19)
at s (http://127.0.0.1:37670/appservice/common/runtime.js:76:17)
at n (http://127.0.0.1:37670/appservice/common/runtime.js:54:35)
at Array.t [as push] (http://127.0.0.1:37670/appservice/common/runtime.js:44:38)
at http://127.0.0.1:37670/appservice/common/main.js:4:57
at require (http://127.0.0.1:37670/appservice/dev/WASubContext.js?t=wechat&s=1674014606052&v=2.12.3:11:2062644)
at r (http://127.0.0.1:37670/appservice/dev/WASubContext.js?t=wechat&s=1674014606052&v=2.12.3:11:2061244)
at http://127.0.0.1:37670/appservice/app.js:8:1(env: Windows,mp,1.05.2204250; lib: 2.12.3)

2023-01-18 12:17 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com (作者)

帮助菜单切换回上一版本是灰色的不能选。
找到了个3.6.17的覆盖了。
打包微信小程序,发现在2.16.0之下的还是会报错,不过内容不一样
app.js错误:
ReferenceError: globalThis is not defined
at Object.bc2e (vendor.js? [sm]:14)
at s (runtime.js? [sm]:3)
at Object.d (main.js? [sm]:1)
at s (runtime.js? [sm]:3)
at n (runtime.js? [sm]:3)
at Array.t [as push] (runtime.js? [sm]:3)
at main.js? [sm]:1
at require (WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2)
at WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2
at app.js? [sm]:4(env: Windows,mp,1.05.2204250; lib: 2.16.0)
(anonymous) @ VM319:9
doWhenAllScriptLoaded @ VM285:3658
scriptLoaded @ VM285:3686
(anonymous) @ VM285:3711
Promise.then (async)
(anonymous) @ VM285:3732
(anonymous) @ VM285:3736
loadScripts @ assubloader.js:1
async function (async)
loadScripts @ assubloader.js:1
loadAppResourceScripts @ assubloader.js:1
(anonymous) @ app-service.js:1
WAServiceMainContext.js:2 Uncaught FrameworkError
globalThis is not defined
ReferenceError: globalThis is not defined
at Object.bc2e (http://127.0.0.1:61159/appservice/common/vendor.js:7750:13)
at s (http://127.0.0.1:61159/appservice/common/runtime.js:76:17)
at Object.d (http://127.0.0.1:61159/appservice/common/main.js:94:19)
at s (http://127.0.0.1:61159/appservice/common/runtime.js:76:17)
at n (http://127.0.0.1:61159/appservice/common/runtime.js:54:35)
at Array.t [as push] (http://127.0.0.1:61159/appservice/common/runtime.js:44:38)
at http://127.0.0.1:61159/appservice/common/main.js:4:57
at require (http://127.0.0.1:61159/appservice/dev/WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2:2440460)
at http://127.0.0.1:61159/appservice/dev/WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2:2439629
at http://127.0.0.1:61159/appservice/app.js:8:1(env: Windows,mp,1.05.2204250; lib: 2.16.0)
B @ WAServiceMainContext.js:2
c @ VM13 asdebug.js:1
r @ VM13 asdebug.js:1
window.onerror @ VM272:10
doWhenAllScriptLoaded @ VM285:3658
scriptLoaded @ VM285:3686
(anonymous) @ VM285:3711
error (async)
t.default @ VM272:10
(anonymous) @ VM272:10
n @ VM272:1
(anonymous) @ VM272:1
(anonymous) @ VM272:1
WAServiceMainContext.js:2 ReferenceError: globalThis is not defined
at Object.bc2e (vendor.js? [sm]:14)
at s (runtime.js? [sm]:3)
at Object.d (main.js? [sm]:1)
at s (runtime.js? [sm]:3)
at n (runtime.js? [sm]:3)
at Array.t [as push] (runtime.js? [sm]:3)
at main.js? [sm]:1
at require (WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2)
at WASubContext.js?t=wechat&s=1674016928980&v=2.16.0:2
at app.js? [sm]:4(env: Windows,mp,1.05.2204250; lib: 2.16.0)

1***@qq.com

1***@qq.com

同样遇到这个问题。。。。知道怎么处理了吗,虽然不影响更新

  • 3***@qq.com (作者)

    切换基础库到2.16.0以上

    2023-04-11 16:44

要回复问题请先登录注册