我在使用Flow Router时很难加载模板。如果我在/client/app.html中包含我的模板 -
{{ input type="checkbox" disabled=checkbox.disabled checked=checkbox.value}} {{checkbox.label}}
我在/lib/routes.js中的路线 -
<body>
{{> applicationLayout}}
</body>
<template name="applicationLayout">
<header>
{{> Template.dynamic template=header}}
</header>
</template>
<template name="mainMenu">
<ul>
<li>who we are </li>
<li>what we do</li>
<li>where we work</li>
</ul>
</template>
然后一切正常。但我想拆分我的模板。所以我创建了/imports/ui/components/main-menu.html
FlowRouter.route( '/terms', {
action: function() {
BlazeLayout.render( 'applicationLayout', {
header: 'mainMenu',
} );
},
name: 'termsOfService', // Optional route name.
});
我从/client/app.html删除模板,然后将以下导入添加到我的/lib/routes.js顶部
<template name="mainMenu">
<h2> {{currentPage}} </h2>
<ul>
{{#each pages }}
<li> {{ page.headerTitle }} </li>
{{/each}}
</ul>
</template>
现在我收到以下错误 -
import '/imports/ui/components/main-menu.js';
我无法弄清楚这里发生了什么。如何拆分我的模板?
更新
所以我设法通过将我的包含放在/Users/aidan/.meteor/packages/meteor-tool/.1.3.2_4.1s3pnfi++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
throw(ex);
^
Error: Cannot find module './main-menu.html'
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:78:1)
at meteorInstall.imports.ui.components.main-menu.js (imports/ui/components/main-menu.js:5:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
at meteorInstall.lib.routes.js (lib/routes.js:1:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
at /Users/aidan/Code/edu-finance/.meteor/local/build/programs/server/app/app.js:239:1
at /Users/aidan/Code/edu-finance/.meteor/local/build/programs/server/boot.js:283:10
at Array.forEach (native)
Exited with code: 8
Your application is crashing. Waiting for file change.
中来获得某个地方。这是按照我的预期展示的东西。我不确定这是构建一切的最佳方式。而我仍然想知道在/client/app.js