返回介绍

Ionic4 路由组件 ion-router-outlet

发布于 2019-11-22 18:04:18 字数 2956 浏览 1270 评论 0 收藏 0

Ionic4项目中我们可以使用Ionic4路由组件ion-router-outlet对项目进行布局。

ion-router-outlet官方文档地址:https://ionicframework.com/docs/api/router-outlet

Router Outlet is a component used in routing within an Angular app. Router Outlet behaves in a similar way as Angular's built-in Router Outlet component, but contains the logic for providing a stacked navigation, and animating views in and out.

Note: this is only meant for Angular projects. For vanilla JavaScript, use ion-router and ion-route instead.

While Router Outlet has methods for navigating around, it's recommended to use the navigation methods in Angular's router.

Life Cycle Hooks

Routes rendered in a Router Outlet have access to specific Ionic events that are wired up to animations

Event NameTrigger
ionViewWillEnterFired when the component being routed to is about to animate in.
ionViewDidEnterFired when the component being routed to has animated in.
ionViewWillLeaveFired when the component being routed from is about to animate.
ionViewDidLeaveFired when the component being routed from has animated.

These event tie into Ionic's animation system and can be used to coordinate parts of your app when a Components is done with it's animation. These events are not a replacement for Angular's own event system, but an addition.

For handling Router Guards, the older ionViewCanEnter and ionViewCanLeave have been replaced with their framework specific equivalent. For Angular, there are Router Guards.

ion-router-outlet 属性(Properties)

animated

Description

If true, the router-outlet should animate the transition of components.

Attributeanimated
Typeboolean
Defaulttrue

animation

Description

By default ion-nav animates transition between pages based in the mode (ios or material design). However, this property allows to create custom transition using AnimateBuilder functions.

Type((Animation: Animation, baseEl: any, opts?: any) => Promise<Animation>) | undefined

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文