フロールータパッケージの助けを借りてルーティングを適用しようとしています。しかし、それは私が期待していたものとして私のために働いていません。私は自分のコードを共有します、私が間違っている場所を教えてください!前もって感謝します。FlowRouterの助けを借りて流星が私のために働いていない
FlowRouter.route('/',{
name:'home',
action(){
BlazeLayout.render("HomeLayout");
}
});
FlowRouter.route('/test',{
name:'test',
action(){
BlazeLayout.render('MainLayout',{main:'Test'});
}
});
localhost:3000/test
にアクセスすると、次のエラーが発生します。
modules-runtime.js:36Uncaught Error: Cannot find module './main.html'
Exception in defer callback: Error: Expected template or null, found: undefined
at ._render (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:61:13)
at doRender (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2027:25)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:20
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:29
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:339:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:229:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:604:11)
私が間違っているところを教えてください。コードに変更を加える必要がありますか?
は、ここに私のindex.htmlファイルのコードです:
<head>
<title>intermediate-meteor</title>
</head>
ここに私のMainLayout.htmlである:ここでは
<template name="MainLayout">
<header>
<h1>My Recipe Book</h1>
</header>
<main>
{{>Template.dyanamic template=main}}
</main>
</template>
<template name="Test">
<h1>Test Template Rendering form Main Template...!!</h1>
</template>
私HomeLayout.htmlです:
<template name="HomeLayout">
<header>
<h1>My Recipe Book</h1>
</header>
<main>
<div class="billboard">
<h2>Organize your meals</h2>
</div>
</main>
</template>
パッケージ。 jasonファイルコード:
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
[email protected] # Packages every Meteor app needs to have
[email protected] # Packages for a great mobile UX
[email protected] # The database Meteor supports right now
[email protected] # Compile .html files into Meteor Blaze views
[email protected] # Reactive variable for tracker
[email protected] # Helpful client-side library
[email protected] # Meteor's client-side reactive programming library
[email protected] # CSS minifier run for production mode
[email protected] # JS minifier run for production mode
[email protected] # ECMAScript 5 compatibility for older browsers.
[email protected] # Enable ECMAScript2015+ syntax in app code
[email protected] # Server-side component of the `meteor shell` command
kadira:flow-router
kadira:blaze-layout
私のコードを見て、どこに間違いをしているのか教えてください。そして、あなたがルートにどのようなURLからロードされるどのようなテンプレートを制御できindex.html
<head>
<title>intermediate-meteor</title>
</head>
<body>
{{> layout}}
</body>
<template name="layout">
{{> Template.dynamic template=main}}
</template>
:
私はメインテンプレートであるMainLayout.htmlを作成しました。私はHomeLayout.htmlを作成しました。そして、私は "Test"という名前でMainLayout.htmlのテンプレートを作成し、私が使用しているフロールートに従ってroute.jsでルーティングするコードを記述するためにindex.htmlを持っています私のプロジェクトでは、それは私が望むように私のために働いていない..!完了したコードを共有できますか?申し訳ありませんが、私はまだ流星に慣れていないので、私はどこに間違っているのか分かりません。 –
また、「install.js:101Uncaught Error:モジュール './main.html'を見つけることができません」というエラーが表示されます。私のミスはどこですか? –
'kadira:flow-router'と' kadira:blaze-layout'の両方がインストールされていますか?たぶんあなたのHTMLファイルをあなたのポストに追加して、それらを見ることができます。 – gkrizek