uni-app的uniCloud Admin在H5模式下无法运行

uni-app的uniCloud Admin在H5模式下无法运行

HBuilderX版本

版本号
3.1.18

UniCloud版本

版本号
1.5.3

您好,我在HX最新版中用UNICloud admin创建项目,在未绑定云空间时可以正常打开登录页面。

绑定云空间后,运行H5模式就报错“Uncaught ReferenceError: uni is not defined at Object.getStorageSync (chunk-vendors.js:12742)”。

我在评论区已看到多条关于此问题的提问,仍未得到解决。希望能尽早就此问题得到解决,谢谢。


更多关于uni-app的uniCloud Admin在H5模式下无法运行的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

Bug已确认,感谢反馈

更多关于uni-app的uniCloud Admin在H5模式下无法运行的实战教程也可以访问 https://www.itying.com/category-93-b0.html


终于等到你,感谢,希望尽快修复,我就可以开始玩耍了ヾ(o◕∀◕)ノヾ

这个问题是因为uniCloud Admin在H5模式下缺少uni API支持导致的。错误信息"uni is not defined"表明uni对象未正确初始化。

解决方案:

  1. 检查uni-app基础库版本:确保使用的是支持uniCloud的稳定版本,建议升级到3.1.22+版本

  2. 检查manifest.json配置

{
  "h5": {
    "devServer": {
      "disableHostCheck": true
    }
  }
}
  1. 重新安装依赖
npm install
  1. 清理缓存:删除node_modules和package-lock.json,重新npm install

  2. 检查云函数依赖:确认云函数中未使用仅小程序端支持的API

临时解决方案: 在main.js中加入以下代码:

// #ifdef H5
if (typeof uni === 'undefined') {
  global.uni = require('[@dcloudio](/user/dcloudio)/uni-h5')
}
// #endif
回到顶部