Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
The <menu> component serves as a temporary pop-up window to display operations that users can perform. For details, see menu.
Create a <menu> component in the .hml file under pages/index and add the target, type, and title attributes.
- <!-- xxx.hml-->
- <div class="container">
- <text class="title-text" id="textId">show menu</text>
- <menu target="textId" type="click" title="title">
- <option value="Item 1">Item 1</option>
- <option value="Item 2">Item 2</option>
- <option value="Item 3">Item 3</option>
- </menu>
- </div>
- /* xxx.css */
- .container{
- width: 100%;
- height: 100%;
- flex-direction: column;
- background-color: #F1F3F5;
- align-items: center;
- justify-content: center;
- width: 100%;
- }
- .title-text{
- font-size: 35px;
- }

The <menu> component supports only the option child component.
The <menu> component does not support the focusable and disabled attributes.
Set the style for the <menu> component, such as the font color, size, and character spacing.
- <!-- xxx.hml-->
- <div class="container">
- <text class="title-text" id="textId">show menu</text>
- <menu target="textId" type="click" title="title">
- <option value="Item 1">Item 1</option>
- <option value="Item 2">Item 2</option>
- <option value="Item 3">Item 3</option>
- </menu>
- </div>
- /* xxx.css */
- .container{
- width: 100%;
- height: 100%;
- flex-direction: column;
- background-color: #F1F3F5;
- align-items: center;
- justify-content: center;
- width: 100%;
- }
- .title-text{
- font-size: 35px;
- background-color: #5a5aee;
- color: white;
- width: 70%;
- text-align: center;
- height: 85px;
- border-radius: 12px;
- }
- .menu{
- text-color: blue;
- font-size: 35px;
- letter-spacing: 2px;
- }
- option{
- color: #6a6aef;
- font-size: 30px;
- }

Bind the oncancel event to the <menu> component. (The event is triggered when an operation is canceled.)
- <!-- xxx.hml-->
- <div class="container">
- <text class="title-text" id="textId" onclick="textClick">show menu</text>
- <menu title="title" oncancel="cancel" id="menuId">
- <option value="Item 1">Item 1</option>
- <option value="Item 2">Item 2</option>
- <option value="Item 3">Item 3</option>
- </menu>
- </div>
- /* xxx.css */
- .container{
- width: 100%;
- height: 100%;
- flex-direction: column;
- background-color: #F1F3F5;
- width: 100%;
- }
- .title-text{
- font-size: 35px;
- background-color: #5a5aee;
- color: white;
- width: 70%;
- text-align: center;
- height: 85px;
- border-radius: 12px;
- margin-top: 500px;
- margin-left: 15%;
- }
- menu{
- text-color: blue;
- font-size: 35px;
- letter-spacing: 2px;
- }
- option{
- color: #6a6aef;
- font-size: 30px;
- }
- // xxx.js
- export default {
- cancel() {
- this.getUIContext().getPromptAction().showToast({
- message: "cancel"
- })
- },
- textClick() {
- this.$element("menuId").show({ x: 175,y: 590 });
- }
- }

Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.