繁体   English   中英

灰烬路线未显示模板内容

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM