gpt4 book ai didi

meteor - 用户电子邮件未显示在模板 [METEOR] 中!

转载 作者:行者123 更新时间:2023-12-05 01:00:19 25 4
gpt4 key购买 nike

我有一个用户索引,想显示每个用户的信息。用户 ID 显示正常,但应用程序不显示电子邮件。

这是我的模板:

<template name="users">
<h1>List of all users</h1>
{{#each users}}
<div class="list_item">
<p>ID: {{_id}}</p>
<p>Email: {{email}}</p>
</div>
{{/each}}
</template>

这是我的路线:
Router.route('/users', function () {
this.render('users');
}, {
waitOn: function() {
return [
Meteor.subscribe('users')
]
},

data: {users: Meteor.users.find({})}
});

最后,我的出版物:
Meteor.publish('users', function () {
return Meteor.users.find({}, {fields: {emails: 1, profile: 1}});
});

有任何想法吗?

最佳答案

显示电子邮件的正确方法是:

<p>Email: {{emails.[0].address}}</p>

电子邮件地址作为数组存储在用户对象中。

您可以输入 Meteor.user() 来查看在控制台中:
Object {
...
emails: Array[1]
0: Object{
address: "username@domain.com",
verified: false
}
...
}

关于meteor - 用户电子邮件未显示在模板 [METEOR] 中!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29457921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com