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/