9***@qq.com
9***@qq.com
  • 发布:2025-12-03 22:30
  • 更新:2025-12-03 22:31
  • 阅读:12

【报Bug】uni-upgrade-center-app报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: macOs Tahoe 26.1

HBuilderX类型: 正式

HBuilderX版本号: 4.76

手机系统: Android

手机系统版本号: Android 13

手机厂商: 小米

手机机型: 小米13 PRo

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

一、打开插件市场
二、搜索uni-upgrade-center-app,并导入至项目中
三、按照文档说明进行配置
四、运行

预期结果:

在各个端均正常运行

实际结果:

在app端不报错,但是H5端报错导致无法正常进行调试开发。

bug描述:

通过插件市场导入了uni-upgrade-center-app[0.9.7],并且按照文档说明正确引入了,在app端不报错,但是在H5端运行报错:
项目 ulink 开始编译
当前项目的uniCloud使用的默认服务空间spaceId为:
​当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinh5​
请注意运行模式下,因日志输出、sourcemap以及未压缩源码等原因,性能和包体积,均不及发行模式。
正在编译中...
INFO Starting development server...
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/call-check-version.ts:94
TS2558:Expected 0 type arguments, but got 1.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/call-check-version.ts:99
TS2304:Cannot find name 'UniCloudError'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/call-check-version.ts:105
TS18046:'e' is of type 'unknown'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:229
TS1005:'}' expected.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:4
TS2307:Cannot find module '@/uni_modules/uts-openSchema' or its corresponding type declarations.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:10
TS2355:A function whose declared type is neither 'void' nor 'any' must return a value.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:82
TS2339:Property 'openDialogPage' does not exist on type 'Uni'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:85
TS7006:Parameter 'err' implicitly has an 'any' type.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:122
TS2451:Cannot redeclare block-scoped variable 'confirmText'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:125
TS2451:Cannot redeclare block-scoped variable 'confirmText'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:208
TS2339:Property 'installApk' does not exist on type 'Uni'.
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/check-update.ts:215
TS7006:Parameter 'err' implicitly has an 'any' type.

在H5页中报:
/项目路径/uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
[tsl] ERROR at uni_modules/uni-upgrade-center-app/utils/call-check-version.ts:94
TS2558:Expected 0 type arguments, but got 1.

2025-12-03 22:30 负责人:无 分享
已邀请:
Ask小助手

Ask小助手 - Ask社区AI助手

您的问题是由于uni-upgrade-center-app插件在H5端存在TypeScript类型定义不兼容导致的。根据错误日志,主要问题包括:

  1. TS2304: Cannot find name 'UniCloudError' - 缺少云函数错误类型定义
  2. TS2307: Cannot find module '@/uni_modules/uts-openSchema' - uts插件在H5平台不支持
  3. 多个TS2339错误 - H5平台缺少App端特有的API类型定义

解决方案:

  1. 升级HBuilderX:当前您使用4.76正式版,建议升级至最新正式版(4.85)或alpha版(4.86),新版已修复多平台TypeScript兼容性问题 HBuilderX版本说明

  2. H5平台限制:uni-upgrade-center-app主要设计用于App端,H5平台不支持应用商店更新功能。H5应用更新应通过常规前端部署方式实现,而非使用此插件。

  3. 条件编译处理:在调用插件方法时使用条件编译,仅在App平台执行相关代码:

    // #ifdef APP-PLUS  
    import upgrade from '@/uni_modules/uni-upgrade-center-app/js_sdk'  
    upgrade.checkUpdate()  
    // #endif
  4. TypeScript配置:检查项目根目录tsconfig.json,确保包含@dcloudio/types

    {  
    "compilerOptions": {  
    "types": ["@dcloudio/types"]  
    }  
    }

参考文档:uni-app TypeScript支持指南H5调试指南

内容为 AI 生成,仅供参考

要回复问题请先登录注册