Html 我怎样才能删除“#&引用;在Ionic中刷新页面时不会出现错误
我正在构建一个Ionic PWA,在其中我实现了深度链接Html 我怎样才能删除“#&引用;在Ionic中刷新页面时不会出现错误,html,angular,url,ionic3,Html,Angular,Url,Ionic3,我正在构建一个Ionic PWA,在其中我实现了深度链接 IonicModule.forRoot(MyApp, {}, { links: [ { component: FeaturedPage, name: 'FeaturedPage', segment: ':title' }, { component: HomePage, name: 'HomePage', segment: ':title' },
IonicModule.forRoot(MyApp, {}, {
links: [
{ component: FeaturedPage, name: 'FeaturedPage', segment: ':title' },
{ component: HomePage, name: 'HomePage', segment: ':title' },
{ component: LatestPage, name: 'LatestPage', segment: ':title' },
{ component: TopPage, name: 'TopPage', segment: ':title' },
{ component: TrendingPage, name: 'TrendingPage', segment: ':title' },
{ component: ListPage, name: 'ListPage', segment: ':title' },
{ component: ItemDetailsPage, name: 'ItemDetailsPage', segment: 'Categories/:category' }
]
}),
默认情况下,它生成的URL包含“#”。
根据要求,我必须删除“#”,所以我做了研究,发现在下面的帮助下,我可以从URL中删除“#”
import { LocationStrategy, PathLocationStrategy } from '@angular/common';
{ provide: LocationStrategy, useClass: PathLocationStrategy },
我在成绩上取得了成功。现在URL不包含“#”
然而,当我刷新这个页面时,我得到了一个错误
我知道,为了克服这类错误,需要在URL中添加“#”,但现在我不想出现“#”,也不想在刷新页面后出现错误,有没有人可以告诉我如何消除这类错误?我想这可能会有帮助,您使用哪台服务器来服务您的应用程序?如果是webpack dev server,请查看
devServer.historyapi fallback
option@yurzui现在,我正在本地主机上测试它,但稍后将使用Apache。另请参阅@yurzui,因此我需要在Apache上配置它,为此,我需要在Apache服务器的根目录中重写.htaccess文件的规则。在我的项目中是否需要进行任何配置?如何在localhost上也解决这个问题?