-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (45 loc) · 1.1 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VanJS Router V2</title>
</head>
<body>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/vanjs-org/van/public/van-1.5.2.nomodule.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanjs-router@latest/dist/vanjs-router.min.js"></script>
<script>
const { Route, goto } = router
const { div, button } = van.tags
const Home = () => Route({
rule: 'home',
Loader() {
return div(
'This Is Home Page.',
button({ onclick: () => goto('about') }, 'Go To About')
)
},
onFirst() {
console.log('home onfirst')
},
onLoad() {
console.log('home onload')
},
})
const About = () => Route({
rule: 'about',
delayed: true,
Loader() {
return div(
'This Is About Page.',
button({ onclick: () => goto('home') }, 'Go To Home')
)
},
onLoad() {
this.show()
}
})
van.add(document.body, Home(), About())
</script>
</body>
</html>