umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.33k stars 2.65k forks source link

[Bug] 配置base之后,路由会叠加两次base #11676

Closed frankcou closed 1 year ago

frankcou commented 1 year ago

What happens?

前提:我只有一个路由地址,为/booking 配置base为/aaaaaaaaaaaaa/之后,访问localhost:4118/aaaaaaaaaaaaa/booking,会跳转到localhost:4118/aaaaaaaaaaaaa/aaaaaaaaaaaaa/booking

浏览器显示警告:No routes matched location "/aaaaaaaaaaaaa/booking"

Mini Showcase Repository(REQUIRED)

这个是我config.local.ts的配置:

import { defineConfig } from '@umijs/max';

export default defineConfig({
  publicPath: '/',
  base: '/aaaaaaaaaaaaa/', 
  chainWebpack(memo, args) {
    return memo;
  },
});

config.ts配置:

import { defineConfig } from '@umijs/max';
import zhCN from 'antd/locale/zh_CN';

const title  = 'ffff'
export default defineConfig({
  title, 
  layout: { title }, // 全局layout配置
  access: {},
  model: {},
  initialState: {},
  request: {},
  clickToComponent: { editor: 'vscode' },
  autoCSSModules: true, 
  outputPath: 'booking-app-admin',
  history: { type: 'browser' },
  publicPath: '/booking-app-admin/', // 资源位置
  base: '/booking-app-admin/', //基础路由
  hash: true,
  // routes: routes,
  mfsu: {
    esbuild: true, //首次启动更快,但二次编译不会有物理缓存
  },
  analyze: {
    analyzerMode: 'server', //server, static, json, disabled
  },
  npmClient: 'cnpm',
});

相关依赖:

Context

github-actions[bot] commented 1 year ago

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

fz6m commented 1 year ago

我使用最新版本 4.0.81 的 umi 依赖时,没遇到这个问题,当你配置了 base/aaaaaaaaaaaaa 时,访问 / 路径会自动跳转到 /aaaaaaaaaaaaa/ ,这是符合预期的。

如有问题,需要给一个可以复现的仓库链接。

yoke0104x commented 11 months ago

aaaaaaaaaaaaa

我知道这个问题是为什么,是因为跳转时不是/xxx/xxx的路由而是用了location.pathname 导致的

zhubincode commented 11 months ago

怎么解决的