W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
以垂直列表形式顯示的菜單。
- @Entry
- @Component
- struct Index {
- @State select: boolean = true
- private iconStr: ResourceStr = $r("app.media.view_list_filled")
- private iconStr2: ResourceStr = $r("app.media.view_list_filled")
- @Builder
- SubMenu() {
- Menu() {
- MenuItem({ content: "復(fù)制", labelInfo: "Ctrl+C" })
- MenuItem({ content: "粘貼", labelInfo: "Ctrl+V" })
- }
- }
- @Builder
- MyMenu(){
- Menu() {
- MenuItem({ startIcon: $r("app.media.icon"), content: "菜單選項" })
- MenuItem({ startIcon: $r("app.media.icon"), content: "菜單選項" })
- .enabled(false)
- MenuItem({
- startIcon: this.iconStr,
- content: "菜單選項",
- endIcon: $r("app.media.arrow_right_filled"),
- builder: this.SubMenu.bind(this)
- })
- MenuItemGroup({ header: '小標(biāo)題' }) {
- MenuItem({ content: "菜單選項" })
- .selectIcon(true)
- .selected(this.select)
- .onChange((selected) => {
- console.info("menuItem select" + selected);
- this.iconStr2 = $r("app.media.icon");
- })
- MenuItem({
- startIcon: $r("app.media.view_list_filled"),
- content: "菜單選項",
- endIcon: $r("app.media.arrow_right_filled"),
- builder: this.SubMenu.bind(this)
- })
- }
- MenuItem({
- startIcon: this.iconStr2,
- content: "菜單選項",
- endIcon: $r("app.media.arrow_right_filled")
- })
- }
- }
- build() {
- Row() {
- Column() {
- Text('click to show menu')
- .fontSize(50)
- .fontWeight(FontWeight.Bold)
- }
- .bindMenu(this.MyMenu)
- .width('100%')
- }
- .height('100%')
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: