亲爱的,请告知如何正确显示每个待办事项的作者。 我将authorId添加到Todos集合中,制作了帮助程序并更正了发布,但它不起作用:我在浏览器中看到作者的个人资料,但不知道如何将名称传递给todo。
我猜想 https://github.com/meteor/todos/blob/master/imports/ui/components/lists-show.js 中的 todoArgs(todo) 中的问题因为 todoAuthor 未传递。
希望得到任何帮助/评论。
todos.js
Todos.helpers({
todoAuthor: function() {
return Meteor.users.findOne(this.authorId);
}
});
出版物.js
children: [{
find(list) {
return Todos.find({ listId: list._id }, { fields: Todos.publicFields });
},
children: [
{
find: function(username, list) {
return Meteor.users.find(
{ _id: username.authorId },
{ fields: { profile: 1 } });
}
}
]
}],
todos-item.html
<template name="Todos_item">
{{todoAuthor.profile.name}}
</template>
最佳答案
我已经使用 {{#let}} 找到了临时解决方案,但很高兴听到有关此事的最佳实践。谢谢。
关于javascript - Meteor todoapp 中 todo 的作者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39810308/