Skip to content

作者

novlan1

2025.9.6

路由模式不匹配

不匹配

业务路由模式是 history,但是研发平台配置成 hash,会造成什么?

  • 白屏

history 模式设置

Vue3 项目

ts
import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
} from 'vue-router';

const router = createRouter({
  history: ROUTE_MODE === 'hash'
    ? createWebHashHistory()
    : createWebHistory(import.meta.env.VITE_ROUTER_BASE || '/'),
  routes,
});

Vue3 uni-app 项目:

json
{
 "h5": {
    "router": {
      "mode": "history",
      "base": "/"
    }
  }
}