首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Meteor动态模板不工作

Meteor动态模板不工作
EN

Stack Overflow用户
提问于 2017-03-03 23:13:53
回答 1查看 459关注 0票数 1

第{{> Template.dynamic template=content }}行使我的页面无法加载。它有时真的会让我的浏览器崩溃。我让它工作了一段时间,但发生了一些事情,现在它不再工作了。{{> Template.dynamic template='navBar‘}}可以工作,所以我的包应该没问题。

Meteor: 1.4软件包: kadira:flow-router,kadira:blaze-layout

导入/ui/layouts/mainLayout.html:

代码语言:javascript
复制
<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/layouts/mainLayout.js:

代码语言:javascript
复制
import { Template } from 'meteor/templating';
import './mainLayout.html';
import '../components/navBar.html';
import '../pages/settings.html';

imports/startup/client/routes.js:

代码语言:javascript
复制
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/pages/settings.html:

代码语言:javascript
复制
<template name="settings">
  <div class="container">
    <h1>This is the settings page</h1>
  </div>
</template>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-03 23:30:08

此路由:

代码语言:javascript
复制
FlowRouter.route('/', {
  action() {
    BlazeLayout.render('mainLayout', { content: 'mainLayout' });
  },
});

是不会起作用的,因为您将mainLayout组件插入到自身中-嵌套的content帮助器才是问题所在。相反,您应该将不同的组件呈现到content

代码语言:javascript
复制
BlazeLayout.render('mainLayout', { content: 'home' }); // or whatever component should be at "/"
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42582454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档