2017-03-03 20 views
1

{{Template.Tynamic template = content}}行は、私のページを読み込まないようにします。実際にはブラウザがクラッシュすることがあります。私はそれがしばらくの間働いていたが、何かが起こって、今はもう働かない。 {{> Template.dynamic template = 'navBar'}}は動作しますので、私のパッケージはokです。Meteor Dynamic Template not working

流星: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