|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 6 | + <title>Menu</title> |
| 7 | + <link rel="stylesheet" href="../../../common.css" /> |
| 8 | + <script src="../../../common.js"></script> |
| 9 | + <script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script> |
| 10 | + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" /> |
| 11 | + |
| 12 | + <script type="module"> |
| 13 | + import { menuController } from 'https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/index.esm.js'; |
| 14 | + window.menuController = menuController; |
| 15 | + </script> |
| 16 | + </head> |
| 17 | + |
| 18 | + <body> |
| 19 | + <ion-app> |
| 20 | + <ion-menu menu-id="first-menu" content-id="main-content"> |
| 21 | + <ion-header> |
| 22 | + <ion-toolbar> |
| 23 | + <ion-title>First Menu</ion-title> |
| 24 | + </ion-toolbar> |
| 25 | + </ion-header> |
| 26 | + <ion-content class="ion-padding">This is the first menu content.</ion-content> |
| 27 | + </ion-menu> |
| 28 | + |
| 29 | + <ion-menu menu-id="second-menu" content-id="main-content"> |
| 30 | + <ion-header> |
| 31 | + <ion-toolbar> |
| 32 | + <ion-title>Second Menu</ion-title> |
| 33 | + </ion-toolbar> |
| 34 | + </ion-header> |
| 35 | + <ion-content class="ion-padding">This is the second menu content.</ion-content> |
| 36 | + </ion-menu> |
| 37 | + |
| 38 | + <ion-menu side="end" content-id="main-content"> |
| 39 | + <ion-header> |
| 40 | + <ion-toolbar> |
| 41 | + <ion-title>End Menu</ion-title> |
| 42 | + </ion-toolbar> |
| 43 | + </ion-header> |
| 44 | + <ion-content class="ion-padding">This is the end menu content.</ion-content> |
| 45 | + </ion-menu> |
| 46 | + |
| 47 | + <div class="ion-page" id="main-content"> |
| 48 | + <ion-header> |
| 49 | + <ion-toolbar> |
| 50 | + <ion-title>Menu</ion-title> |
| 51 | + </ion-toolbar> |
| 52 | + </ion-header> |
| 53 | + <ion-content class="ion-padding"> |
| 54 | + <p>Tap a button below to open a specific menu.</p> |
| 55 | + |
| 56 | + <ion-button expand="block" onclick="openFirstMenu()">Open First Menu</ion-button> |
| 57 | + <ion-button expand="block" onclick="openSecondMenu()">Open Second Menu</ion-button> |
| 58 | + <ion-button expand="block" onclick="openEndMenu()">Open End Menu</ion-button> |
| 59 | + </ion-content> |
| 60 | + </div> |
| 61 | + </ion-app> |
| 62 | + |
| 63 | + <script> |
| 64 | + async function openFirstMenu() { |
| 65 | + // Open the menu by menu-id |
| 66 | + await menuController.enable(true, 'first-menu'); |
| 67 | + await menuController.open('first-menu'); |
| 68 | + } |
| 69 | + |
| 70 | + async function openSecondMenu() { |
| 71 | + // Open the menu by menu-id |
| 72 | + await menuController.enable(true, 'second-menu'); |
| 73 | + await menuController.open('second-menu'); |
| 74 | + } |
| 75 | + |
| 76 | + async function openEndMenu() { |
| 77 | + // Open the menu by side |
| 78 | + await menuController.open('end'); |
| 79 | + } |
| 80 | + </script> |
| 81 | + </body> |
| 82 | +</html> |
0 commit comments