-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (48 loc) · 1.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<meta charset="utf-8">
<title>Mobile App</title>
<!-- Ionic -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@latest/css/ionic.bundle.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@latest/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core@latest/dist/ionic/ionic.js"></script>
<my-router></my-router>
<script>
class MyRouter extends HTMLElement {
constructor() {
super()
this.document = new URLSearchParams(window.location.search).get('shadow') === 'true'
? this.attachShadow({ mode: 'open' })
: this
}
connectedCallback() {
this.document.innerHTML = `
<ion-router>
<ion-route url="/" component="page-one"></ion-route>
<ion-route url="/page-two" component="page-two"></ion-route>
</ion-router>
<ion-router-outlet></ion-router-outlet>
`;
}
}
class PageOne extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<ion-content class="ion-padding">
This is the content for page 1.
<ion-router-link href="#/page-two">
<ion-button>Go to Page 2</ion-button>
</ion-router-link>
</ion-content>`;
}
}
class PageTwo extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<ion-content class="ion-padding">
This is the content for page 2.
</ion-content>`;
}
}
customElements.define('my-router', MyRouter);
customElements.define('page-one', PageOne);
customElements.define('page-two', PageTwo);
</script>