Javascript meteor iron路由器,数据未呈现
我有一个meteor项目,其中我试图呈现一个带有url数据的页面,但是meteor没有呈现正确的模板 这是我的铁路由器代码:Javascript meteor iron路由器,数据未呈现,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,我有一个meteor项目,其中我试图呈现一个带有url数据的页面,但是meteor没有呈现正确的模板 这是我的铁路由器代码: Router.map(function() { this.route('profile', { path: '/profile/:_id', template: 'profile', data: function () { console.info(this); return Meteor.users.findOne({
Router.map(function() {
this.route('profile', {
path: '/profile/:_id',
template: 'profile',
data: function () {
console.info(this);
return Meteor.users.findOne({_id: this.params._id});
}
}),
this.route('info'),
this.route('home', {
path:'/',
}),
...
和(简单)模板:
<template name="profile">
{{user}}
</template>
我知道Meteor会经过这条路径,因为router函数中的console.info()会在控制台中转储一个对象三次(!)。
然而,我只能看到我的主页,我从来没有到个人资料页
我能找到的所有信息都来自iron router教程或文档,并显示了我的确切代码。
以前有人有过这个问题吗?我做错了什么
更新: 我还注意到,当我向路由添加一个动作函数时,该函数从不运行
action : function () {
console.info("action running!");
if (this.ready()) {
this.render();
}
}
我想这里没有你介绍的东西。您只需要发布用户集合中的数据。
好吧,看来我犯了个愚蠢的错误: 我阻止了对配置文件的访问,除非它是您自己的配置文件。
我用错误的用户id测试了对我页面的访问。我不认为这是我做错的。我已经出版并订阅了我的收藏。在我的应用程序的其他地方,我可以完全访问用户(服务器端或客户端)。
action : function () {
console.info("action running!");
if (this.ready()) {
this.render();
}
}