-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
61 lines (55 loc) · 1.75 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
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MicroToy</title>
</head>
<body>
<div>this is main page</div>
<button id="btnOne">home</button>
<button id="btnTwo">load vue</button>
<button id="btnThree">load react</button>
<div id="MICRO_CONTAINER"></div>
<script type="module">
import { createLayer } from "./index.js";
const layer = createLayer();
const container = document.querySelector("#MICRO_CONTAINER");
layer.registerMicroApps([
{
name: "react-app",
entry: [
"//localhost:3000/static/js/bundle.js",
],
container,
isActive: () => window.location.pathname.includes("/react"),
publicPath: '//localhost:3000/',
},
{
name: "vue-app",
entry: [
"//localhost:8001/js/chunk-vendors.js",
"//localhost:8001/js/app.js",
],
container,
isActive: () => window.location.pathname.includes("/vue"),
publicPath: '//localhost:8001/',
baseUrl: '/vue'
},
]);
const btnOne = document.querySelector('#btnOne');
btnOne.addEventListener('click', () => {
window.location.href = '/'
});
const btnTwo = document.querySelector('#btnTwo');
btnTwo.addEventListener('click', () => {
window.history.pushState('', null, '/vue')
});
const btnThree = document.querySelector('#btnThree');
btnThree.addEventListener('click', () => {
window.history.pushState('', null, '/react')
});
</script>
</body>
</html>