行{{> Template.dynamic template = content}}使我的页面无法加载。它实际上有时会崩溃我的浏览器。我让它工作了一段时间但事情发生了,现在它不再起作用了。 {{> Template.dynamic template ='navBar'}}正常工作,所以我的包应该没问题。
流星:1.4 包:kadira:flow-router,kadira:blaze-layout进口/ UI /布局/ mainLayout.html:
<template name="mainLayout">
<header>
<div class="container">
{{> navBar }}
</div>
</header>
<body>
<div class="container">
{{> Template.dynamic template=content }} <!-- not working -->
</div>
</body>
<footer>
<div class="container">
<h3>Footer</h3>
</div>
</footer>
</template>
进口/ UI /布局/ mainLayout.js:
import { Template } from 'meteor/templating';
import './mainLayout.html';
import '../components/navBar.html';
import '../pages/settings.html';
进口/启动/客户端/ routes.js:
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import '../../ui/layouts/mainLayout.js';
import '../../ui/pages/settings.js';
FlowRouter.route('/', {
action() {
BlazeLayout.render('mainLayout', { content: 'mainLayout' });
},
});
FlowRouter.route('/settings', {
action() {
BlazeLayout.render('mainLayout', { content: 'settings' });
},
});
进口/ UI /页/ settings.html:
<template name="settings">
<div class="container">
<h1>This is the settings page</h1>
</div>
</template>
答案 0 :(得分:2)
这条路线:
FlowRouter.route('/', {
action() {
BlazeLayout.render('mainLayout', { content: 'mainLayout' });
},
});
不会起作用,因为您将mainLayout
组件插入其自身 - 嵌套的content
帮助程序是个问题。相反,您应该将另一个组件呈现为content
:
BlazeLayout.render('mainLayout', { content: 'home' }); // or whatever component should be at "/"