提交 64628096 编写于 作者: E ester.zhou

udpate ts-methods-menu.md (7747)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 fff73e30
# Menu # Menu
> **NOTE**<br> The menu bound to a component through [bindContextMenu](./ts-universal-attributes-menu.md#Atrributes) on a page can be closed as needed.
> **NOTE**
>
> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
None
## ContextMenu.close ## ContextMenu.close
| API | Description | | API | Description |
| ---- | --- | | ---- | --- |
|close(): void| Closes the menu bound to this component through [bindContextMenu](./ts-universal-attributes-menu.md#Atrributes) on a page. | |close(): void| Closes the menu bound to this component through [bindContextMenu](./ts-universal-attributes-menu.md#Atrributes) on a page. |
- Example
``` ## Example
```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Index { struct Index {
@Builder MenuBuilder(){ @Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('close') Text('close')
.fontSize(30) .fontSize(30)
...@@ -26,14 +37,15 @@ ...@@ -26,14 +37,15 @@
.backgroundColor(Color.Pink) .backgroundColor(Color.Pink)
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
Column(){ Column() {
Text("Text") Text("Text")
}.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) }.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册