0

我已经使用 angular 7 完成了我的路由,如果我使用菜单键跟随路径,它工作正常。但是,如果我在一个页面上并尝试刷新浏览器,它会给我 404 错误。同样,我不能直接访问任何单个页面,我必须使用按钮访问所有页面。我的代码示例:这是我的路由文件的一部分

const routes: Routes = [
  {
    path:'',component:Component1
  },
  {
    path: 'home', component: Component2
  }]

我的索引具有 bas ref 为:

<base href="/myforms/">

我正在使用以下内容访问 component2:

<div class="col-sm-6">
              <a routerLink="home" router-link-Active="active" ><button class="btn btn-green">Home</button></a>              
            </div>

它工作正常我得到了网址:localhost:8091/myforms/home,当我点击按钮时它会打开。但是如果我刷新我的页面,它会给我 404。

如果您对此问题有任何了解,请帮助我。先感谢您。

4

0 回答 0