在 angular2 dart 中,默认情况下从路由中删除了 hashbang,这使得 URL 变得很好。但是,当我使用 pubserve 运行应用程序时,我无法刷新根目录以外的任何页面,或者收到 404 消息,例如“无法在包 angular2_quickstart 中找到 Assets web/仪表板。”
我知道必须有一个简单的解决方案。
有没有办法强制 pubserve 捕获主机上的所有路由并始终像单页应用程序一样提供index.html?或者在本地开发和提供应用程序的开发人员工作流程是什么?
这个问题类似,但我不想使用 hashbang:Angular2 Routing gives 404 when reloading page
最佳答案
pubserve
不支持 PathLocationStrategy
要么使用一些代理来添加对 PathLocationStrategy
的支持,要么将 Angular2 配置为使用 HashLocationStrategy
bootstrap(AppComponent, const Provider(LocationStrategy, useClass: HashLocationStrategy)]);
关于dart - Angular2 Dart 与 pubserve localhost 刷新页面 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40563419/