我不确定为什么吗?,我用谷歌搜索了几次,什么都没有出现...
<img src={this.props.user.picture || this.props.user.gravatar} />
{' '}{this.props.user.name || this.props.user.email || this.props.user.id}{' '}
更新: 抱歉,应该早于此
Gravatar的辅助方法
userSchema.methods.gravatar = function(size) {
console.log(gravatar);
if (!size) {
size = 200;
}
if (!this.email) {
return `https://gravatar.com/avatar/?s=${size}&d=retro`;
}
const md5 = crypto.createHash('md5').update(this.email).digest('hex');
return `https://gravatar.com/avatar/${md5}?s=${size}&d=retro`;
};
和猫鼬的用户模型:
var userSchema = new mongoose.Schema({
name: String,
email: { type: String, unique: true, lowercase: true}, password: String,
passwordResetToken: String,
passwordResetExpires: Date,
gender: String,
location: String,
website: String,
picture: String,
...