umijs / plugin-layout

Umi plugin for ant-design-pro-layout build-in .
MIT License
13 stars 7 forks source link

hash 路由模式时菜单不能正常选中 #12

Closed onlyling closed 4 years ago

onlyling commented 4 years ago

按照 umi3 的「快速上手」创建项目,添加路由。

export default defineConfig({
  nodeModulesTransform: {
    type: 'none',
  },
  layout: {
    name: 'AAAA',
    fixedHeader: true,
    fixSiderbar: true,
    // locale: true,
    navTheme: 'light',
  },
 // 使用 hash 路由时菜单无法正常选中
  history: {
    type: 'hash',
  },
  routes: [
    { path: '/', redirect: '/home' },
    { path: '/home', component: '@/pages/index', name: '首页' },
    { path: '/list', component: '@/pages/list', name: '列表' },
  ],
});
{
  "private": true,
  "scripts": {
    "start": "umi dev",
    "build": "umi build",
    "postinstall": "umi generate tmp",
    "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
    "test": "umi-test",
    "test:coverage": "umi-test --coverage"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,less,md,json}": [
      "prettier --write"
    ],
    "*.ts?(x)": [
      "prettier --parser=typescript --write"
    ]
  },
  "dependencies": {
    "@ant-design/pro-layout": "^5.0.12",
    "@umijs/preset-react": "1.x",
    "@umijs/test": "^3.2.2",
    "lint-staged": "^10.0.7",
    "prettier": "^1.19.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "umi": "^3.2.2",
    "yorkie": "^2.0.0"
  }
}

相似问题:添加 base 或者开启 hash 时菜单不能正常选中

已修复

plugins/packages/plugin-layout/CHANGELOG.md

0.11.7 (2020-06-03) Bug Fixes layout: fix hash router no work bugfix (#247) (2c35415)

查看详情

pandapandaQ commented 4 years ago

我也遇到类似的问题,同求解决方案。