[英]Ember route not displaying template content
我是Ember和JS的新手,到目前為止,我發現最廣泛的教程是使用1.0.0 pre2,但是在官方站點上有一個非常不錯的描述以及1.0.0 pre4的一些示例。 我開始使用它。 我被困在路由中,這是我的代碼:
的index.html
<body>
Loaded.
<script type="text/x-handlebars" data-template-name="application">
In template displaying val: {{name}}
{{#linkTo "index"}}<img class="logo">{{/linkTo}}
<nav>
{{#linkTo "about"}}About{{/linkTo}}
{{#linkTo "favorites"}}Favorites{{/linkTo}}
</nav>
</script>
<script type="text/x-handlebars" data-template-name="about">
Here comes the about text: {{str}}
</script>
</body>
app.js
window.App = Ember.Application.create();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
})
App.ApplicationController = Ember.Controller.extend({
name: 'test'
})
App.AboutView = Ember.View.extend({
templateName: 'about'
})
App.AboutController = Ember.Controller.extend({
str: 'my string'
})
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
它幾乎與該站點中的相同。 我想要並認為應該發生的事情是,它將顯示about模板的內容,而只是將url更新為/#/ about或/#/ favs。 我在這里想念什么?
我想要並認為應該發生的事情是,它將顯示about模板的內容,而只是將url更新為/#/ about或/#/ favs。 我在這里想念什么?
您的應用程序模板沒有{{outlet}}
。 有了它,它將按預期工作。
有關工作示例,請參見此jsbin 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.