运行程序就报错

- 发布:2025-08-29 12:29
- 更新:2025-08-29 13:07
- 阅读:29
【报Bug】uni-admin的登陆页,疑似因为没有使用顶部和左侧边栏模板,导致Cannot read properties of null (reading '$') 报错
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: mac 15.6.1
HBuilderX类型: 正式
HBuilderX版本号: 4.76
浏览器平台: Chrome
浏览器版本: 139.0.7258.128(正式版本) (arm64)
项目创建方式: HBuilderX
操作步骤:
预期结果:
无报错
无报错
实际结果:
有报错
有报错
bug描述:
pages.json 中,凡是 配置了"topWindow": false,"leftWindow": false的页面,都报错:
uni-h5.es.js:16350 [Vue warn]: Unhandled error during execution of watcher callback
at <Layout>
at <App>
warnHandler @ uni-h5.es.js:16350
callWithErrorHandling @ vue.runtime.esm.js:1418
warn$1 @ vue.runtime.esm.js:1243
logError @ vue.runtime.esm.js:1475
errorHandler @ uni-h5.es.js:16149
callWithErrorHandling @ vue.runtime.esm.js:1418
handleError @ vue.runtime.esm.js:1458
(anonymous) @ vue.runtime.esm.js:1428
Promise.catch
callWithAsyncErrorHandling @ vue.runtime.esm.js:1427
job @ vue.runtime.esm.js:3197
callWithErrorHandling @ vue.runtime.esm.js:1418
flushJobs @ vue.runtime.esm.js:1623
Promise.then
queueFlush @ vue.runtime.esm.js:1532
queueJob @ vue.runtime.esm.js:1526
scheduler @ vue.runtime.esm.js:3219
resetScheduling @ vue.runtime.esm.js:263
triggerEffects @ vue.runtime.esm.js:307
triggerRefValue @ vue.runtime.esm.js:1067
set value @ vue.runtime.esm.js:1112
finalizeNavigation @ vue-router.mjs:3361
(anonymous) @ vue-router.mjs:3226
Promise.then
pushWithRedirect @ vue-router.mjs:3193
push @ vue-router.mjs:3118
install @ vue-router.mjs:3559
use @ vue.runtime.esm.js:5200
initRouter @ uni-h5.es.js:16261
install @ uni-h5.es.js:16330
use @ vue.runtime.esm.js:5200
(anonymous) @ main.js:35
vue.runtime.esm.js:1480 TypeError: Cannot read properties of null (reading '$')
at updateWindow (uni-h5.es.js:23701:41)
logError @ vue.runtime.esm.js:1480
errorHandler @ uni-h5.es.js:16149
callWithErrorHandling @ vue.runtime.esm.js:1418
handleError @ vue.runtime.esm.js:1458
(anonymous) @ vue.runtime.esm.js:1428
Promise.catch
callWithAsyncErrorHandling @ vue.runtime.esm.js:1427
job @ vue.runtime.esm.js:3197
callWithErrorHandling @ vue.runtime.esm.js:1418
flushJobs @ vue.runtime.esm.js:1623
Promise.then
queueFlush @ vue.runtime.esm.js:1532
queueJob @ vue.runtime.esm.js:1526
scheduler @ vue.runtime.esm.js:3219
resetScheduling @ vue.runtime.esm.js:263
triggerEffects @ vue.runtime.esm.js:307
triggerRefValue @ vue.runtime.esm.js:1067
set value @ vue.runtime.esm.js:1112
finalizeNavigation @ vue-router.mjs:3361
(anonymous) @ vue-router.mjs:3226
Promise.then
pushWithRedirect @ vue-router.mjs:3193
push @ vue-router.mjs:3118
install @ vue-router.mjs:3559
use @ vue.runtime.esm.js:5200
initRouter @ uni-h5.es.js:16261
install @ uni-h5.es.js:16330
use @ vue.runtime.esm.js:5200
(anonymous) @ main.js:35
uni-h5.es.js:16350 [Vue warn]: Unhandled error during execution of watcher callback
at <Layout>
at <App>
warnHandler @ uni-h5.es.js:16350
callWithErrorHandling @ vue.runtime.esm.js:1418
warn$1 @ vue.runtime.esm.js:1243
logError @ vue.runtime.esm.js:1475
errorHandler @ uni-h5.es.js:16149
callWithErrorHandling @ vue.runtime.esm.js:1418
handleError @ vue.runtime.esm.js:1458
(anonymous) @ vue.runtime.esm.js:1428
Promise.catch
callWithAsyncErrorHandling @ vue.runtime.esm.js:1427
job @ vue.runtime.esm.js:3197
callWithErrorHandling @ vue.runtime.esm.js:1418
flushJobs @ vue.runtime.esm.js:1623
Promise.then
queueFlush @ vue.runtime.esm.js:1532
queueJob @ vue.runtime.esm.js:1526
scheduler @ vue.runtime.esm.js:3219
resetScheduling @ vue.runtime.esm.js:263
triggerEffects @ vue.runtime.esm.js:307
triggerRefValue @ vue.runtime.esm.js:1067
set value @ vue.runtime.esm.js:1112
finalizeNavigation @ vue-router.mjs:3361
(anonymous) @ vue-router.mjs:3226
Promise.then
pushWithRedirect @ vue-router.mjs:3193
push @ vue-router.mjs:3118
install @ vue-router.mjs:3559
use @ vue.runtime.esm.js:5200
initRouter @ uni-h5.es.js:16261
install @ uni-h5.es.js:16330
use @ vue.runtime.esm.js:5200
(anonymous) @ main.js:35
vue.runtime.esm.js:1480 TypeError: Cannot read properties of null (reading '$')
at updateWindow (uni-h5.es.js:23723:41)
logError @ vue.runtime.esm.js:1480
errorHandler @ uni-h5.es.js:16149
callWithErrorHandling @ vue.runtime.esm.js:1418
handleError @ vue.runtime.esm.js:1458
(anonymous) @ vue.runtime.esm.js:1428
Promise.catch
callWithAsyncErrorHandling @ vue.runtime.esm.js:1427
job @ vue.runtime.esm.js:3197
callWithErrorHandling @ vue.runtime.esm.js:1418
flushJobs @ vue.runtime.esm.js:1623
Promise.then
queueFlush @ vue.runtime.esm.js:1532
queueJob @ vue.runtime.esm.js:1526
scheduler @ vue.runtime.esm.js:3219
resetScheduling @ vue.runtime.esm.js:263
triggerEffects @ vue.runtime.esm.js:307
triggerRefValue @ vue.runtime.esm.js:1067
set value @ vue.runtime.esm.js:1112
finalizeNavigation @ vue-router.mjs:3361
(anonymous) @ vue-router.mjs:3226
Promise.then
pushWithRedirect @ vue-router.mjs:3193
push @ vue-router.mjs:3118
install @ vue-router.mjs:3559
use @ vue.runtime.esm.js:5200
initRouter @ uni-h5.es.js:16261
install @ uni-h5.es.js:16330
use @ vue.runtime.esm.js:5200
(anonymous) @ main.js:35
uni-h5.es.js:16350 [Vue warn]: Unhandled error during execution of watcher callback
at <Layout>
at <App>
warnHandler @ uni-h5.es.js:16350
callWithErrorHandling @ vue.runtime.esm.js:1418
warn$1 @ vue.runtime.esm.js:1243
logError @ vue.runtime.esm.js:1475
errorHandler @ uni-h5.es.js:16149
callWithErrorHandling @ vue.runtime.esm.js:1418
handleError @ vue.runtime.esm.js:1458
callWithErrorHandling @ vue.runtime.esm.js:1420
callWithAsyncErrorHandling @ vue.runtime.esm.js:1425
job @ vue.runtime.esm.js:3197
callWithErrorHandling @ vue.runtime.esm.js:1418
flushJobs @ vue.runtime.esm.js:1623
flushJobs @ vue.runtime.esm.js:1633
Promise.then
queueFlush @ vue.runtime.esm.js:1532
queueJob @ vue.runtime.esm.js:1526
(anonymous) @ vue.runtime.esm.js:7494
resetScheduling @ vue.runtime.esm.js:263
triggerEffects @ vue.runtime.esm.js:307
triggerRefValue @ vue.runtime.esm.js:1067
set value @ vue.runtime.esm.js:1112
(anonymous) @ vue.runtime.esm.js:3805
Promise.then
setup @ vue.runtime.esm.js:3804
callWithErrorHandling @ vue.runtime.esm.js:1418
setupStatefulComponent @ vue.runtime.esm.js:8991
setupComponent @ vue.runtime.esm.js:8952
mountComponent @ vue.runtime.esm.js:7265
processComponent @ vue.runtime.esm.js:7231
patch @ vue.runtime.esm.js:6699
mountChildren @ vue.runtime.esm.js:6947
mountElement @ vue.runtime.esm.js:6854
processElement @ vue.runtime.esm.js:6819
patch @ vue.runtime.esm.js:6687
mountChildren @ vue.runtime.esm.js:6947
mountElement @ vue.runtime.esm.js:6854
processElement @ vue.runtime.esm.js:6819
patch @ vue.runtime.esm.js:6687
mountChildren @ vue.runtime.esm.js:6947
mountElement @ vue.runtime.esm.js:6854
processElement @ vue.runtime.esm.js:6819
patch @ vue.runtime.esm.js:6687
mountChildren @ vue.runtime.esm.js:6947
mountElement @ vue.runtime.esm.js:6854
processElement @ vue.runtime.esm.js:6819
patch @ vue.runtime.esm.js:6687
mountChildren @ vue.runtime.esm.js:6947
mountElement @ vue.runtime.esm.js:6854
processElement @ vue.runtime.esm.js:6819
patch @ vue.runtime.esm.js:6687
componentUpdateFn @ vue.runtime.esm.js:7375
run @ vue.runtime.esm.js:180
instance.update @ vue.runtime.esm.js:7500
setupRenderEffect @ vue.runtime.esm.js:7510
mountComponent @ vue.runtime.esm.js:7277
processComponent @ vue.runtime.esm.js:7231
patch @ vue.runtime.esm.js:6699
componentUpdateFn @ vue.runtime.esm.js:7375
run @ vue.runtime.esm.js:180
instance.update @ vue.runtime.esm.js:7500
setupRenderEffect @ vue.runtime.esm.js:7510
mountComponent @ vue.runtime.esm.js:7277
processComponent @ vue.runtime.esm.js:7231
patch @ vue.runtime.esm.js:6699
render2 @ vue.runtime.esm.js:8021
mount @ vue.runtime.esm.js:5278
app.mount @ vue.runtime.esm.js:11140
(anonymous) @ main.js:35
vue.runtime.esm.js:1480 TypeError: el.getBoundingClientRect is not a function
at updateWindow (uni-h5.es.js:23724:22)
at uni-h5.es.js:23728:5
at callWithErrorHandling (vue.runtime.esm.js:1418:19)
at callWithAsyncErrorHandling (vue.runtime.esm.js:1425:17)
at job (vue.runtime.esm.js:3197:9)
at callWithErrorHandling (vue.runtime.esm.js:1418:33)
at flushJobs (vue.runtime.esm.js:1623:9)
at flushJobs (vue.runtime.esm.js:1633:7)


l***@qq.com (作者)
[广告] 12:44:17.730 uni-admin,开源、完善的后台管理系统,详情
12:44:17.737 项目 test 开始编译
12:44:18.209 请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。
12:44:18.209 vite是按需编译,运行时点击某个未编译页面会先编译后加载,导致显示较慢,发行后无此问题。
12:44:18.209 编译器版本:4.76(vue3)
12:44:18.209 正在编译中...
12:44:18.491 本项目的uniCloud使用的默认服务空间spaceId为:mp-9fad1ce3-3e24-4544-8126-be425c65e9a3
12:44:18.604 Port 5173 is in use, trying another one...
12:44:18.604 当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试。如使用外部浏览器需处理跨域,请将访问页面对应的IP或域名配置在要访问的云函数所在的服务空间的跨域配置内,详见:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinh5
12:44:18.604 vite v5.2.8 dev server running at:
12:44:18.604 - Local: http://localhost:5174/admin/
12:44:18.614 - Network: http://192.168.1.28:5174/admin/
12:44:18.614 项目 test 编译成功。前端运行日志,请另行在浏览器的控制台查看。
12:44:18.614 点击控制台右上角debug图标(虫子),可开启断点调试(添加断点:双击编辑器行号添加断点)
12:44:18.614 Web版常见问题参考: https://ask.dcloud.net.cn/article/35232
12:44:18.614 ready in 618ms.
12:44:19.250 [vite] connecting...
12:44:19.257 [vite] connected.
12:44:19.510 You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
12:44:19.523 %c uni-admin %c v2.5.10 background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold; at App.vue:33
12:44:19.529 App Launch at App.vue:50
12:44:19.529 App Show at App.vue:77
12:44:21.900 [te] { ... } at pages/index/index.vue:303
12:44:21.918 [te] { ... } at pages/index/index.vue:303
12:44:30.552 App Hide at App.vue:81
12:44:30.588 [vite] connecting...
12:44:30.595 [vite] connected.
12:44:30.826 You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
12:44:30.826 %c uni-admin %c v2.5.10 background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold; at App.vue:33
12:44:30.826 App Launch at App.vue:50
12:44:30.833 App Show at App.vue:77
12:44:30.840 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:30.900 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:30.908 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:30.908 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:30.929 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:30.935 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:32.148 App Hide at App.vue:81
12:44:32.178 [vite] connecting...
12:44:32.185 [vite] connected.
12:44:32.338 You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
12:44:32.338 %c uni-admin %c v2.5.10 background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold; at App.vue:33
12:44:32.338 App Launch at App.vue:50
12:44:32.338 App Show at App.vue:77
12:44:32.338 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:32.373 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:32.384 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:32.385 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:32.406 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:32.413 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:34.291 App Hide at App.vue:81
12:44:34.316 [vite] connecting...
12:44:34.370 [vite] connected.
12:44:34.621 You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
12:44:34.621 %c uni-admin %c v2.5.10 background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold; at App.vue:33
12:44:34.621 App Launch at App.vue:50
12:44:34.621 App Show at App.vue:77
12:44:34.621 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:34.656 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:34.664 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:34.664 [TypeError] {message: "Cannot read properties of null (reading '$')"} at js_sdk/uni-admin/error.js:30
12:44:34.695 [Vue warn]: Unhandled error during execution of watcher callback \n at <Layout>\nat <App>
12:44:34.718 [TypeError] {message: "Cannot read properties of null (reading '$')"}
12:44:48.484 App Hide at App.vue:81
12:44:55.869 App Show at App.vue:77
12:44:57.176 App Hide at App.vue:81