Javascript 如何使用Meteor Iron Router创建单独的模板HTML文件
我有三个文件夹 客户 路由器 服务器 在客户端文件夹中,还有一个名为视图的文件夹,其中包含一个名为layout.html、home.html和login.html的文件 在路由器文件夹中有一个router.js文件,其中包含Javascript 如何使用Meteor Iron Router创建单独的模板HTML文件,javascript,meteor,url-routing,iron-router,Javascript,Meteor,Url Routing,Iron Router,我有三个文件夹 客户 路由器 服务器 在客户端文件夹中,还有一个名为视图的文件夹,其中包含一个名为layout.html、home.html和login.html的文件 在路由器文件夹中有一个router.js文件,其中包含 Router.configure({ layoutTemplate: "Layout" }); Router.route( "/", function(){ this.render( "Home" ); }); Router.route( "/login", f
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渲染很好,但找不到主模板
如果我将所有模板都包含在layout.html中,那么routing works 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,使其与我上面描述的内容相匹配,然后一切又恢复正常。我将把这个留在这里,以防其他人碰到这个问题。几天前我遇到了类似的问题 如果您使用的是Meteor 1.2版,可能由于以下问题而无法正常工作: 您可以通过检查是否出现以下异常来确认:
Exception in callback of async function: ReferenceError: EJSON is not defined
因此,虽然他们不更新包来修复它,但添加“ejson”包:
meteor add ejson
之后,它应该会工作。几天前我遇到了类似的问题 如果您使用的是Meteor 1.2版,可能由于以下问题而无法正常工作: 您可以通过检查是否出现以下异常来确认:
Exception in callback of async function: ReferenceError: EJSON is not defined
因此,虽然他们不更新包来修复它,但添加“ejson”包:
meteor add ejson
之后,它应该可以工作。你能分享主页模板吗?啊,我忘了文件名是home.ng.html,因为我也在尝试使用meteor angular。删除ng和路由有效。你能共享home模板吗?啊,我忘了文件名是home.ng.html,因为我也在尝试使用meteor angular。移除ng和管线会起作用。