更新时间:2022-12-14 22:54:12
首先关闭,您在评论中引用了离子原生v3。然而,离子 - 天然和离子不是一回事。当您提出问题时,Ionic v3尚未正式发布,因此除非您使用测试版,否则我认为您仍然使用v2。
First off, you are referencing ionic-native v3 in your comment. However, ionic-native and ionic are not the same thing. Ionic v3 was not officially released when you asked your question, so unless you used the beta version, I assume that you still use v2.
您不需要角度路由器用于URL路径。在Ionic v2中,您可以这样做:
You don't need angular router for URL paths. In Ionic v2, you can do it like that:
app.module.ts
app.module.ts
export const deepLinkConfig: DeepLinkConfig = {
links: [
{ component: Home, name: "home", segment: ""},
{ component: DetailPage, name: "detail", segment: "event/:id", defaultHistory: [Home] }
]
};
然后将其包含在您的导入中:
And then include it in your imports:
IonicModule.forRoot(MyApp, {}, deepLinkConfig)
您现在可以访问 https://example.com/
或 https://example.com/event/访问您应用的页面1
。重新加载网站时, defaultHistory
参数确保您仍然可以使用导航栏导航回上一页。
You can now access the pages of your app by visiting https://example.com/
or https://example.com/event/1
. When reloading the website, the defaultHistory
parameter makes sure that you still have the navigation bar to navigate back to the previous page.
在离子v3中,您可以使用IonicPage注释来配置路线: https: //ionicframework.com/docs/nightly/api/navigation/IonicPage/
In ionic v3, you can use the IonicPage annotation to configure your routes: https://ionicframework.com/docs/nightly/api/navigation/IonicPage/