javascript - Angular2 构建 - 使用有效的子 URL 刷新显示服务器 404 页面

标签 javascript angular typescript

Angular2(带有 typescript )已构建,每当尝试使用有效的子网址刷新时,它都会显示服务器的 404 页面。但在非构建版本中它运行良好。

是否需要做额外的事情来完成这项工作。

假设我的域名是:http://localhost 假设我到达这里: suburl: http://localhost/users 如果我刷新页面,它会显示服务器 404 页面(显示服务器 - apache 或 ngnix 对应的 404 页面)

最佳答案

您需要使用HashLocationStrategy

import {LocationStrategy, HashLocationStrategy} from '@angular/common';

@NgModule({
    ...
    providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],
    ...
})
export class AppModule {}

关于javascript - Angular2 构建 - 使用有效的子 URL 刷新显示服务器 404 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42251445/

相关文章:

javascript - 展开/折叠一个 div 元素?

css - Angular2 - ng2-completer Bootstrap css

javascript - 为什么 TypeScript 有时只能通过字符串索引对象

javascript - 根据 Angular 4 中的某些条件,在子级中单击按钮时,从父级中的数组中删除特定的组件实例

node.js - 错误: Nest cannot export component/module that is not a part of the currently processed module (DatabaseModule)

javascript - 使用文本区域时检查变量是否为空

javascript - 使用 new Audio(),有什么方法可以找出音频文件是否存在?

javascript - 用js和foreach为元素腾出一段时间

angular - 如何使用模拟 websocket 来测试服务功能中的 onMessage?

angular - 为什么 Infragistics Ignite UI 的 Angular ListView 样式不起作用?