流星动态模板不起作用
Meteor Dynamic Template not working
行 {{> Template.dynamic template=content }} 使我的页面无法加载。它有时会使我的浏览器崩溃。我让它工作了一段时间,但发生了一些事情,现在它不再工作了。
{{> Template.dynamic template='navBar' }} 有效,所以我的包裹应该没问题。
流星:1.4
软件包:kadira:flow-路由器,kadira:blaze-布局
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/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' });
},
});
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 "/"
行 {{> Template.dynamic template=content }} 使我的页面无法加载。它有时会使我的浏览器崩溃。我让它工作了一段时间,但发生了一些事情,现在它不再工作了。 {{> Template.dynamic template='navBar' }} 有效,所以我的包裹应该没问题。
流星:1.4 软件包:kadira:flow-路由器,kadira:blaze-布局
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/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' });
},
});
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 "/"