在Meteor中发现一个奇怪的错误:
路线调度从未呈现过。您是否忘记在onBeforeAction中调用this.next()?
并且没有内容呈现。我怎样才能解决这个问题?任何帮助非常感谢。
这是我的router.js
Router.configure({
layoutTemplate: 'layout',
});
Router.route('/', function() {
this.render('home');
});
Router.route('/user/:_username', {
name: 'user_profile',
data: function() { return Meteor.user();}
});
Router.route('/create', function() {
this.render('create_event');
});
Router.route('/events/:name', {
name: 'event',
data: function() { return Events.findOne({name: this.params.name});}
});
Router.route('/useremail', function() {
this.render('userEmail');
}, {
name: 'userEmail'
});
Router._filters = {
hasCompletedProfile: function() {
if(!this.ready()) return;
var user = Meteor.user();
if (user && ! userProfileComplete(user)){
this.render('userEmail');
} else {
this.next();
}
},
};
filters = Router._filters;
Router.onBeforeAction(filters.hasCompletedProfile);
答案 0 :(得分:0)
确保始终使用this.next();
方法拨打Router._filters
,而不仅仅是条件。
尝试将Router._filters
方法替换为:
Router._filters = {
hasCompletedProfile: function() {
if(!this.ready()) return;
var user = Meteor.user();
if (user && ! userProfileComplete(user)){
this.render('userEmail');
}
this.next(); // Take note, it is no longer in an else statement
},
};