行{{> template.dynamic template = content}}}}使我的页面不加载。有时它实际上会使我的浏览器崩溃。我已经工作了一段时间,但是发生了一些事情,现在它不再起作用了。{{> template.dynamic template ='navbar'}}可以正常工作。
流星:1.4包装:Kadira:Flow-Router,Kadira:Blaze-Layout
imports/ui/layouts/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>
imports/ui/layouts/mainlayout.js:
import { Template } from 'meteor/templating';
import './mainLayout.html';
import '../components/navBar.html';
import '../pages/settings.html';
imports/startup/client/doutes.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' });
},
});
imports/ui/pages/settings.html:
<template name="settings">
<div class="container">
<h1>This is the settings page</h1>
</div>
</template>
此路线:
FlowRouter.route('/', {
action() {
BlazeLayout.render('mainLayout', { content: 'mainLayout' });
},
});
由于您将mainLayout
组件插入自身而无法工作 - 嵌套的content
助手是问题。相反,您应该在content
中渲染其他组件:
BlazeLayout.render('mainLayout', { content: 'home' }); // or whatever component should be at "/"