[英]meteor iron router with data not rendering
I have a meteor project in which I'm trying to render a page with url data, however Meteor is not rendering the right template... 我有一个流星项目,我正在尝试使用url数据呈现页面,但是流星没有呈现正确的模板...
This is my iron router code: 这是我的铁路由器代码:
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:'/',
}),
...
and the (simple) template: 和(简单)模板:
<template name="profile">
{{user}}
</template>
with this helper function: 使用此辅助功能:
Template.profile.helpers({
user: function() { return this; }
)};
I know Meteor goes through the route since the console.info() in the router function dumps an object three(!) times in the console. 我知道流星会经过这条路线,因为路由器功能中的console.info()在控制台中转储了对象三(!)次。 However I only get to see my homepage and I never get to the profile page. 但是,我只能看到我的主页,而从未到个人资料页面。
All information I could find about this came from iron router tutorials or the docs and shows (about) the exact code I have. 我能找到的所有信息都来自铁路由器教程或文档,并显示(关于)我的确切代码。 Has anyone had this problem before? 有人遇到过这个问题吗? What am I doing wrong? 我究竟做错了什么?
UPDATE: 更新:
I also noticed that when I add an action function to the route, this function never runs... 我还注意到,当我向路线添加动作功能时,该功能永远不会运行...
action : function () {
console.info("action running!");
if (this.ready()) {
this.render();
}
}
I think there is nothing you have presented here. 我认为您在这里没有介绍任何内容。 You just need to publish data from users collection. 您只需要发布用户集合中的数据。 more about publications 有关出版物的更多信息
Ok seems I made a stupid mistake: 好吧,我似乎犯了一个愚蠢的错误:
I blocked access to a profile unless it is your own profile. 我禁止访问个人资料,除非它是您自己的个人资料。 I was testing the access to my page with the wrong user _id. 我正在使用错误的用户_id测试对页面的访问权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.