Last active
August 29, 2015 13:57
-
-
Save gutenye/9797474 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Ember Hello</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script> | |
<script src="http://builds.emberjs.com/tags/v1.4.0/ember.min.js"></script> | |
</head> | |
<body> | |
<script type="text/x-handlebars" data-template-name="application"> | |
{{#link-to 'index'}}Index{{/link-to}} {{#link-to 'about'}}About{{/link-to}} | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="index"> | |
<h1>INDEX {{name}}</h1> | |
</script> | |
<script type="text/x-handlebars" data-template-name="about"> | |
<h1>About</h1> | |
</script> | |
<script type="text/javascript"> | |
window.App = Ember.Application.create() | |
App.Router.map(function() { | |
this.route("about") | |
}) | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return Ember.Object.create({name: 'HAHA'}) | |
} | |
}) | |
</script> | |
</body> | |
</html> | |
比如你要一个 '/feng' URL
<!-- 先一个feng模板 -->
<script type="text/x-handlebars" data-template-name="feng">
<h1>hi {{name}}</h1>
</script>
<script type="text/javascript">
// 再定义一个route
App.Router.map(function() {
this.route('feng')
})
// 然后给数据
App.FengRoute = Ember.Route.extend({
mode: function() {
return Ember.Object.create({name: 'feng'})
}
})
</script>
这个时候访问 'a.html#/feng' 就出现一个页面了
feng -> FengRoute
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install