forked from RubyLouvre/mmRouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
81 lines (76 loc) · 3.15 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<title>index</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://localhost:3000/style.css"/>
<script src="http://localhost:3000/avalon.js"></script>
<script src="http://localhost:3000/json2.js"></script>
<script>
require("mmRouter", function() {
//使用路由器的几个步骤
//1先加载mmRouter(请将mmRouter.js, mmHistory.js这两个文件与avalon.js放在一起)
//2定义VM
var model = avalon.define('xxx', function(vm) {
vm.currPath = ""
vm.name = "司徒正美"
vm.password = "123456"
vm.param = ""
})
//3定义路由规则
avalon.router.get("/aaa", function(a) {
model.currPath = this.path
})
avalon.router.get("/", function(a) {
model.currPath = "default"
})
avalon.router.get("/bbb", function(a) {
model.currPath = this.path
})
avalon.router.get("/ccc", function(a) {
model.currPath = this.path
})
avalon.router.get("/ddd/:ddd", function(a) {//:ddd为参数
model.param = a
model.currPath = this.path
})
avalon.router.get("/eee", function(a) {
model.currPath = this.path
})
//4启动历史管理器,
avalon.history.start({
html5Mode: true //可以将这里改成false再测试
})
//5开始扫描
avalon.scan()
})
</script>
</head>
<body ms-controller="xxx">
<div id="header">
<ul id="nav">
<li class="fork"><a href="https://github.com/RubyLouvre/avalon">View On GitHub</a></li>
<li class="downloads"><a href="https://github.com/RubyLouvre/avalon/blob/master/avalon.js">ZIP</a></li>
<li class="downloads"><a href="https://github.com/RubyLouvre/avalon">TAR</a></li>
<li class="title">DOWNLOADS</li>
</ul>
</div>
<div class="wrapper">
<h3>高级大气国际化的avalon.js页面</h3>
<div>by 司徒正美</div>
<ul>
<li><a href="#/">default</a></li>
<li><a href="#/aaa">aaa</a></li>
<li><a href="#/bbb">bbb</a></li>
<li><a href="#/ccc">ccc</a></li>
<li><a href="#/ddd/222">ddd</a></li>
<li><a href="#/eee">eee</a></li>
</ul>
<div style="color:red">{{currPath}}</div>
<div style="height: 600px;width:400px;" ms-include-src="currPath.replace(/\/\d+/,'')">
这里用于加载子页面
</div>
<p id="eee">会定位到这里</p>-->
</div>
</body>
</html>