如果有人问过我,请接受我的道歉。我确信这很抱歉,我同样确定这是我所缺少的小事情,无法正确理解。
我在本地运行以下https://autoform.meteorapp.com/updateaf
我专门使用updateaf表单...,并安装了所有必需的软件包,即account-passwords,accounts-ui和account-base。
我的问题是如何在此界面中显示字段名,姓氏和年龄的用户特定数据?
无论我以谁登录,目前我所能获得的都是每次提交。
答案 0 :(得分:0)
我没有特别的updateaf经验,但是我在Meteor上做了很多。
我假设您只想显示当前登录用户的信息并允许他们更新?
如果是这样,我想您将希望拥有只发布当前用户信息的发布(使用Meteor.userId()
,并且您可能必须将People对象的._id链接到Meteor userId),然后自动选择该数据。
更改了您提供的链接(https://autoform.meteorapp.com/updateaf)上Javascript部分的内容:
原始内容(仅显示与selectedPersonId
相关的内容,其余全部在链接上):
Meteor.publish(null, function () {
return People.find();
});
Template.updateaf.helpers({
selectedPersonDoc() {
return People.findOne(Session.get("selectedPersonId"));
},
isSelectedPerson() {
return Session.equals("selectedPersonId", this._id);
}
});
Template.updateaf.events({
'click .person-row'() {
Session.set("selectedPersonId", this._id);
}
});
更改为(而不是显示所有用户并通过单击来允许他们更改,只需返回与流星用户相对应的单个用户即可)(您可能必须更改/删除一些其他js函数才能摆脱“人列表”)
Meteor.publish(null, function () {
return People.findOne({ _id: Meteor.userId() );
});
Template.updateaf.helpers({
selectedPersonDoc() {
return People.findOne({ _id: Meteor.userId() );
}
});
如果您有任何疑问,请告诉我,希望对您有所帮助。
如果需要,一些其他教程: https://guide.meteor.com/data-loading.html https://themeteorchef.com/tutorials/publication-and-subscription-patterns