当我开始遇到错误时,我正在使用流星中的用户帐户。控制台中打印的错误在我的userEmail
辅助函数中。我的问题是,如果是undefined
这样,为什么我会得到输出?
我的html代码:
{{#each user}}
{{#if student}}
<div class="row">
<div class="user-wrapper">
<div class="row">
<div class="name-wrapper col-md-3">
<span class="head">{{profile.firstname}}</span>
</div>
<div class="email-wrapper col-md-3">
<span class="head">{{userEmail}}</span>
</div>
<div class="email-wrapper col-md-3">
<span class="head">{{>starsRating mutable=true class="js-rate-images" id=_id}}</span>
</div>
<div class="email-wrapper col-md-3">
<span class="head">Remark</span>
<button class="btn btn-primary">Enter Remark</button>
</div>
</div>
</div>
</div>
{{/if}}
{{/each}}
我的辅助功能是:
Template.Users.helpers({
user: function(){
return Meteor.users.find();
},
userEmail:function(){
return this.emails[0].address;
},
student:function(){
return this.profile.profession === 'student';
}
});