uni-app使用uniCloud的H5页面如果直接进入非首页的其他页会错误返回

uni-app使用uniCloud的H5页面如果直接进入非首页的其他页会错误返回

操作步骤:

预期结果:

实际结果:

bug描述:

使用 uniCloud 的 H5 页面不通过首页,直接输入地址进入其他页会如图错误返回
错误截图

信息项 描述
产品分类 uniapp/H5
PC开发环境 Windows
PC开发环境版本号 10
HBuilderX类型 正式
HBuilderX版本号 3.1.2
浏览器平台 Chrome
浏览器版本 88.0.4324.182
项目创建方式 HBuilderX

更多关于uni-app使用uniCloud的H5页面如果直接进入非首页的其他页会错误返回的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

更多关于uni-app使用uniCloud的H5页面如果直接进入非首页的其他页会错误返回的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这个错误是uni-app H5路由模式导致的常见问题。问题核心在于直接访问非首页时,uniCloud的H5页面路由初始化异常。

解决方案:

  1. 在manifest.json中配置H5路由模式为history:
"h5": {
  "router": {
    "mode": "history"
  }
}
  1. 如果必须使用hash模式,需要在服务器配置将所有路由重定向到index.html。以nginx为例:
location / {
  try_files $uri $uri/ /index.html;
}
回到顶部