小编Jan*_*ith的帖子

Mean Stack:刷新或输入直接 URL 会导致“无法获取/”?

我使用 MEAN 堆栈创建了一个网页。角 5。

我遇到的一个问题是我无法输入直接 url 路径。例如,如果我最后输入 /home,则会收到此错误消息“无法获取 /home”。当我点击刷新时也会发生这种情况。该页面完美运行如果我点击主页上的“主页”导航按钮。

例如:这是我的页面:https : //nameless-hollows-54410.herokuapp.com/

当我转到直接链接时,https://nameless-hollows-54410.herokuapp.com/home

页面坏了。为什么会这样?

我的应用程序路由代码:

const routes: Routes  = [
  { path: '', redirectTo: '/home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent},
];
Run Code Online (Sandbox Code Playgroud)

我的导航栏:

<li class="nav-item active">
   <a class="nav-link" routerLink="/home">Home
       <span class="sr-only">(current)</span>
   </a>
</li>
Run Code Online (Sandbox Code Playgroud)

heroku node.js angular angular5

3
推荐指数
1
解决办法
781
查看次数

标签 统计

angular ×1

angular5 ×1

heroku ×1

node.js ×1