【发布时间】:2016-01-02 15:51:52
【问题描述】:
我有三个文件夹
客户
路由器
服务器
在 client 文件夹中还有一个名为 views 的文件夹,其中包含一个名为 layout.html、home.html 和 login.html。
在 router 文件夹中有一个带有
的 router.js 文件Router.configure({
layoutTemplate: "Layout"
});
Router.route( "/", function(){
this.render( "Home" );
});
Router.route( "/login", function(){
this.render( "Login" );
});
在我的 layout.html 文件中
<template name="Layout">
<h1>Hello Layout</h1>
{{ > yield }}
</template>
hello Layout 渲染得很好,但是找不到 home 模板。
如果我在 layout.html 中包含所有模板,则路由工作 4.0。
如何正确管理路由,以便每个模板都可以保留在自己的文件中?
更新 这是其他各自的模板
<template name="Home">
<h1>This Is Home</h1>
</template>
and
<template name="Login">
<h1>This Is Login</h1>
</template>
更新 2
我也在尝试使用meteor-angular,它希望html文件是name.ng.html。
从文件名中删除 ng 以使其与我上面描述的内容相匹配,并且一切正常。我会把这个留在这里,以防其他人遇到这个问题。
【问题讨论】:
-
可以分享主页模板吗?
-
啊,我忘了文件名是 home.ng.html,因为我也在尝试使用流星角。删除 ng 和路由工作。
标签: javascript meteor url-routing iron-router