【发布时间】:2014-12-05 16:23:18
【问题描述】:
我的问题与problem 有关,因为我也有同样的问题。如果我有这样的路线:
this.route('userPage', {
path: '/user/:username',
waitOn: function() { return [Meteor.subscribe('userPage', this.params.username)];
},
data: function() {
return Users.findOne({username: this.params.username});
}
});
我的订阅看起来像这样:
Meteor.publish('userPage', function(username) {
return Users.find({username: username}, {fields: {'profile': 1, 'username': 1}});
});
将呈现 404 页面(这很好),但 progress-bar 挂在 98% 左右(为什么?)。 如果我有这样的路线:
this.route('chat', {
path: '/chat/:slug',
waitOn: function() { return [ Meteor.subscribe('chat', this.params.slug), Meteor.subscribe('chatAvatars', this.params.slug) ]; },
data: function() { return Chat.findOne({slug: this.params.slug}); }
});
我的订阅是这样的:
Meteor.publish('chat', function(slug) {
return Chat.find({slug: slug});
});
Meteor.publish('chatAvatars', function(slug) {
var chat = Chat.findOne({slug: slug});
if (chat) {
return Users.find({_id: {$in: chat.participants}}, {fields: {'profile.image': 1, 'username': 1}});
} else {
return null;
}
});
不会呈现 404 not found 模板。为什么?如果聊天存在,我是否必须签入我的onBeforeAction?
【问题讨论】:
标签: javascript meteor iron-router