2017-03-03 115 views
1

该行{{> Template.dynamic template = content}}使得我的页面无法加载。有时它实际上会使我的浏览器崩溃。我让它工作了一段时间,但发生了一些事情,现在它不再工作了。 {{> Template.dynamic template ='navBar'}}有效,所以我的包应该没问题。流星动态模板不起作用

流星:1.4 套餐:kadira:流路由器,kadira:闪耀布局

进口/ 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

所以,你正在布局内的布局? 'BlazeLayout.render('mainLayout',{content:'mainLayout'});' – chazsolo

回答

2

这条路线:

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

是行不通的,因为你要插入的mainLayout组件到本身 - 嵌套content帮手是问题。相反,你应该渲染一个不同的组件到content

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

我做了一些文件的重命名工作,我的大脑在这个过程中停止了工作。谢谢。有用。 – user3323307