Javascript 显示404未找到'的模板;鼻涕虫';当发布返回空游标-流星-铁路由器时
我的问题与此相关,因为我有同样的问题。如果我有这样的路线:Javascript 显示404未找到'的模板;鼻涕虫';当发布返回空游标-流星-铁路由器时,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,我的问题与此相关,因为我有同样的问题。如果我有这样的路线: this.route('userPage', { path: '/user/:username', waitOn: function() { return [Meteor.subscribe('userPage', this.params.username)]; }, data: function() { return Users.findOne({username: this.param
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}});
});
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;
}
});
我的订阅如下所示:
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}});
});
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页面将被呈现(这很好),但挂起率为98%左右(为什么?)。
如果我有这样的路线:
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}});
});
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;
}
});
我的订阅是这样的:
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}});
});
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未找到的模板。为什么?如果聊天存在,我必须在操作前签入我的
吗?您忘记将发布设置为就绪
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 {
this.ready();//<============here
}
});
Meteor.publish('chatAvatars',函数(slug){
var chat=chat.findOne({slug:slug});
如果(聊天){
返回Users.find({u id:{$in:chat.participants},{fields:{'profile.image':1,'username':1}});
}否则{
这个;//谢谢你的帮助!现在404找不到模板被呈现了,但是你能告诉我为什么进度条一直没有完成吗?不知怎么的,你的一个订阅从来没有准备好。你确定你在服务器端没有错误吗?或者你能给我一个小的github repo,我可以检查你做了什么吗?我现在不能提供github repo,但是谢谢谢谢你的帮助!你知道我如何“调试”这个吗?progressDebug
模式没有真正的帮助:/Maybe使用DDP Analyzer proxy检查你的DDP日志,或者尝试在没有iron router的情况下订阅,看看是IRP没有完成加载还是订阅。