Angular 角度:使用“GitHub”页面重新加载后获取“404”

Angular 角度:使用“GitHub”页面重新加载后获取“404”,angular,github-pages,Angular,Github Pages,我已经在GitHub页面上部署了我的Angular网站,但我遇到了一个问题 以下是我的路线设置: const routes:routes=[ {路径:'',重定向到:'main',路径匹配:'full'}, {路径:'main',组件:AppMainComponent} ]; 以下是我的部署命令: -名称:构建 运行:| npm安装-g@angular/cli npm安装 ng build--prod--base href=https://[user name].github.io/[proj

我已经在
GitHub
页面上部署了我的
Angular
网站,但我遇到了一个问题

以下是我的
路线设置:

const routes:routes=[
{路径:'',重定向到:'main',路径匹配:'full'},
{路径:'main',组件:AppMainComponent}
];
以下是我的部署命令:

-名称:构建
运行:|
npm安装-g@angular/cli
npm安装
ng build--prod--base href=https://[user name].github.io/[project name]/
-名称:部署
使用:JamesIves/github页面部署-action@releases/v2
环境:
GITHUB_令牌:${{secrets.GITHUB_令牌}
BASE_分支机构:master
分行:gh页
文件夹:dist/[项目名称]
如果我转到我的
GitHub
页面“https://[user name].GitHub.io/[project name]/”,它工作正常,并成功重定向到“https://[user name].GitHub.io/[project name]/main”。但在我点击浏览器的重新加载按钮后,它向我显示了
404页面未找到

我的角度版本是9.1.8

谢谢

根据角度,您必须复制
index.html
并将其命名为
404.html

  • 构建完成后,复制docs/index.html并将其命名为docs/404.html
  • bash ng build--prod--output path docs--base href//

    根据Angular,您必须复制
    index.html
    并将其命名为
    404.html

  • 构建完成后,复制docs/index.html并将其命名为docs/404.html
  • bash ng build--prod--output path docs--base href//