每次Meteor.user()运行避免帮手如何改变
问题描述:
我有流星以下帮手:每次Meteor.user()运行避免帮手如何改变
fullname(){
return Meteor.user().currentName;
},
但这帮手运行每次Meteor.user()
变化。我只希望它在用户的currentName
更改时运行,而不仅仅是firstName
。
答
使用.findOne()
和限制返回的键:
fullname(){
return Meteor.users.findOne(Meteor.userId(),{fields: {currentName: 1}}).currentName;
},