我刚刚将Meteor应用程序更新为Meteor v.1.2.0.2和Iron Router v.1.0.12。 Iron Router在客户端持续返回此错误:Couldn't find a template named "layout" or "layout". Are you sure you defined it?
。除此错误外,不会呈现任何内容。这是我的routes.js文件:
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading'
});
Router.route('/', function() {
if (this.ready) {
this.render();
}
else {
this.render('loading');
}
},
{ name: 'main' } );
Router.route('/new/story', { name: 'newStory' } );
Router.route('/story/:_id', { name: 'viewStory', data: function() {
return Stories.findOne(this.params._id);
},
waitOn: function () {
return [Meteor.subscribe("story", this.params._id), Meteor.subscribe("seeds", this.params._id)];
},
onBeforeAction: function() {
var document = Stories.find({ _id: this.params._id }).fetch();
if ($.inArray(Meteor.user()._id, document[0].contributors) === -1) {
this.render('addSeed');
}
else {
this.next();
}
} } );
Router.route('/stories', { name: 'viewStories',
waitOn: function() {
Meteor.subscribe("stories");
}
});
Router.route('/story/:_id/new/seed', { name: 'addSeed', data: function() {
return Seeds.findOne(this.params._id);
}} );
Router.route('/logout', function() {
Meteor.logout();
Router.go("main");
});
布局模板如下所示:
<template name="layout">
{{> nav}}
{{> yield}}
</template>
我不明白什么是错的。请帮忙!
答案 0 :(得分:1)
更新到Meteor v.1.2后,我遇到了同样的错误
事实证明问题出在物化包装上。从0.97.1
到0.97.0
版本的materialize packcage的回滚对我有用。
答案 1 :(得分:0)
确保你有ejson包。如果它丢失了,请用meteor命令添加:
meteor add ejson
确保您也有这个包列表:
meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library
standard-minifiers # JS/CSS minifiers run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code
autopublish # Publish all data to the clients (for prototyping)
insecure # Allow all DB writes from clients (for prototyping)
iron:router
ejson