<!DOCTYPE html> |
< html > |
< head > |
< title >mmRouter组件</ title > |
< meta charset = "UTF-8" > |
< meta name = "viewport" content = "width=device-width" > |
< script src = "../avalon.js" ></ script > |
< style > |
* {word-wrap: break-word;margin:0;padding:0} |
a,a:link { |
color: #000; |
text-decoration: none; |
} |
p { |
padding: 10px; |
} |
.contents { |
margin-top: 20px; |
} |
.contents div { |
padding: 10px; |
margin: 10px; |
border: 1px solid #ccc; |
} |
</ style > |
|
</ head > |
< body > |
< h1 >mmRouter: avalon.state</ h1 > |
< div class = "contents" ms-controller = "test" > |
< p |
ms-repeat-as = "a" > |
< a |
ms-href = "'#!/'+as" >{{as}}</ a > |
</ p > |
< p >------</ p > |
< div |
ms-controller = "form" > |
< div >数据库名:{{db_name}}</ div > |
< div ms-view></ div > |
< div ms-view = 'table' ></ div > |
< div ms-view = 'sql' ></ div > |
</ div > |
</ div > |
< script > |
require(["ready!", "mmRouter/mmState"], function () { |
avalon.define('test', function(vm) { |
vm.a = [ |
"sql", |
"sql/user", |
"sql/user/user", |
"sql/user/admin", |
"sql/user/user/sql", |
"sql/user/admin/sql" |
] |
}) |
avalon.define('form', function(vm) { |
vm.db_name = '暂未获取' |
}) |
avalon.define("table", function(vm) { |
vm.table_name = 'table' |
}) |
avalon.state("form", { |
controller: "test", |
url: "/{source_type}/{db_name}", |
views: { |
"": { |
template: "< div >状态:form</ div >" |
} |
}, |
onEnter: function() { |
avalon.vmodels.form.db_name = this.params ? this.params.db_name + "【从/*/*获取】" : "未获取到db_name" |
} |
}) |
avalon.state("form.table", { |
controller: "form", |
url: "/{table_name}", |
views: { |
"table@": { |
template: "数据库名:{{db_name}}" |
} |
}, |
// abstract: true, |
onEnter: function() { |
avalon.vmodels.form.db_name = this.params ? this.params.db_name + "【从/*/*/*获取】" : "未获取到db_name" |
} |
}); |
avalon.state("form.table.sql", { |
controller: "table", |
url: "/sql", |
views: { |
"sql@": { |
template: "表名:{{table_name}}" |
} |
}, |
onEnter: function() { |
avalon.vmodels.table.table_name = this.params.table_name; |
avalon.vmodels.form.db_name = this.params ? this.params.db_name + "【从/*/*/*/sql获取】" : "未获取到db_name" |
} |
}); |
avalon.history.start({ |
basepath: "/mmRouter", |
fireAnchor: false |
}) |
avalon.scan(); |
}); |
</ script > |
|
</ body > |
</ html > |