我正在尝试在我的 Meteor 应用程序中实现用户更新页面。我的 router.js
:
Router.route('/company/:_id/update/', {
name: 'CompanyUpdate',
data: function() { return Meteor.users.findOne(this.params._id);}
});
我使用的 URL 是(忽略聚合物标签):
<paper-icon-button icon="perm-identity" onclick="location.href='{{pathFor 'CompanyUpdate' _id=userId}}'"></paper-icon-button>
单击该 URL 时,我得到:http://localhost:3000/company/null/update
。它带我到页面,但我无法从用户数据库中获取任何信息。不知道为什么我在 url 中得到一个“null”。
我仍在学习 meteor ,希望有人能解释缺少或做错了什么。
最佳答案
userId
在您的模板中为 null。尝试使用调用 Meteor.user()
的默认 {{currentUser}}
模板。所以这样的事情应该有效:
<paper-icon-button icon="perm-identity" onclick="location.href='{{pathFor 'CompanyUpdate' _id=currentUser._id}}'"></paper-icon-button>
关于javascript - Meteor 中的用户更新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31185433/