ion-menu-controller

概要(CONTENTS)

Ionic4项目中我们可以使用Ionic4侧边栏组件ion-menu-controller对项目进行布局。ion-menu-controller中有ionic ion-menu-controller 内置方法(Methods)等

The Menu Controller makes it easy to control a Menu. The methods provided can be used to display the menu, enable the menu, toggle the menu, and more. The controller will grab a reference to the menu by the side, or id. if neither of these are passed to it, it will grab the first menu it finds.

ion-menu-controller 内置方法(Methods)

close

Description

Close the menu. If no menu is specified, then it will close any menu that is open. If a menu is specified, it will close that menu.

Signature close(menuId?: string | null | undefined) => Promise

enable

Description

Used to enable or disable a menu. For example, there could be multiple left menus, but only one of them should be able to be opened at the same time. If there are multiple menus on the same side, then enabling one menu will also automatically disable all the others that are on the same side.

Signature enable(shouldEnable: boolean, menuId?: string | null | undefined) => Promise

get

Description

Used to get a menu instance. If a menu is not provided then it will return the first menu found. If the specified menu is start or end, then it will return the enabled menu on that side. Otherwise, it will try to find the menu using the menu's id property. If a menu is not found then it will return null.

Signature get(menuId?: string | null | undefined) => Promise

getMenus

Description

Returns an array of all menu instances.

Signature getMenus() => Promise

getOpen

Description

Returns the instance of the menu already opened, otherwise null.

Signature getOpen() => Promise

isAnimating

Description

Returns true if any menu is currently animating.

Signature isAnimating() => Promise

isEnabled

Description

Returns true if the specified menu is enabled.

Signature isEnabled(menuId?: string | null | undefined) => Promise

isOpen

Description

Returns true if the specified menu is open. If the menu is not specified, it will return true if any menu is currently open.

Signature isOpen(menuId?: string | null | undefined) => Promise

open

Description

Open the menu.

Signature open(menuId?: string | null | undefined) => Promise

registerAnimation

Description

Registers a new animation that can be used in any ion-menu.

```

  • ```
Signature registerAnimation(name: string, animation: AnimationBuilder) => void

swipeGesture

Description

Used to enable or disable the ability to swipe open the menu.

Signature swipeGesture(shouldEnable: boolean, menuId?: string | null | undefined) => Promise

toggle

Description

Toggle the menu. If it's closed, it will open, and if opened, it will close.

Signature toggle(menuId?: string | null | undefined) => Promise