返回介绍

Ionic4 路由导航组件 ion-nav

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

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

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

Nav is a standalone component for loading arbitrary components and pushing to new components on to the stack. Unlike RouterOutlet, Nav is not tied to a particular router. Meaning that if we load a Nav component, and push other components to the stack, they will not affect the apps overall router. This fits use cases where you could have a modal, which needs it's own sub-navigation, but not make it tied to the apps URL.

ion-nav 属性(Properties)

animated

Description

If true, the nav 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

root

Description

Root NavComponent to load

Attributeroot
TypeFunction | HTMLElement | ViewController | null | string | undefined

rootParams

Description

Any parameters for the root component

Typeundefined | { [key: string]: any; }

swipeGesture

Description

If the nav component should allow for swipe-to-go-back.

Attributeswipe-gesture
Typeboolean | undefined

ion-nav 事件(Events)

NameDescription
ionNavDidChangeEvent fired when the nav has changed components
ionNavWillChangeEvent fired when the nav will change components

ion-nav 内置方法(Methods)

canGoBack

Description

Returns true if the current view can go back.

SignaturecanGoBack(view?: ViewController | undefined) => Promise<boolean>

getActive

Description

Get the active view.

SignaturegetActive() => Promise<ViewController | undefined>

getByIndex

Description

Get the view at the specified index.

SignaturegetByIndex(index: number) => Promise<ViewController | undefined>

getPrevious

Description

Get the previous view.

SignaturegetPrevious(view?: ViewController | undefined) => Promise<ViewController | undefined>

insert

Description

Inserts a component into the navigation stack at the specified index. This is useful to add a component at any point in the navigation stack.

Signatureinsert(insertIndex: number, component: T, componentProps?: ComponentProps | null | undefined, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

insertPages

Description

Inserts an array of components into the navigation stack at the specified index. The last component in the array will become instantiated as a view, and animate in to become the active view.

SignatureinsertPages(insertIndex: number, insertComponents: NavComponent[], opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

pop

Description

Pop a component off of the navigation stack. Navigates back from the current component.

Signaturepop(opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

popTo

Description

Pop to a specific index in the navigation stack.

SignaturepopTo(indexOrViewCtrl: number | ViewController, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

popToRoot

Description

Navigate back to the root of the stack, no matter how far back that is.

SignaturepopToRoot(opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

push

Description

Push a new component onto the current navigation stack. Pass any additional information along as an object. This additional information is accessible through NavParams.

Signaturepush(component: T, componentProps?: ComponentProps | null | undefined, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

removeIndex

Description

Removes a component from the navigation stack at the specified index.

SignatureremoveIndex(startIndex: number, removeCount?: number, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

setPages

Description

Set the views of the current navigation stack and navigate to the last view. By default animations are disabled, but they can be enabled by passing options to the navigation controller. Navigation parameters can also be passed to the individual pages in the array.

SignaturesetPages(views: any[], opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

setRoot

Description

Set the root for the current navigation stack to a component.

SignaturesetRoot(component: T, componentProps?: ComponentProps | null | undefined, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>

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

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

发布评论

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