流星动态模板不起作用

时间:2017-03-03 15:13:53

标签: meteor meteor-blaze

行{{> 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>

1 个答案:

答案 0 :(得分:2)

这条路线:

FlowRouter.route('/', {
  action() {
    BlazeLayout.render('mainLayout', { content: 'mainLayout' });
  },
});

不会起作用,因为您将mainLayout组件插入其自身 - 嵌套的content帮助程序是个问题。相反,您应该将另一个组件呈现为content

BlazeLayout.render('mainLayout', { content: 'home' }); // or whatever component should be at "/"