wechat4u icon indicating copy to clipboard operation
wechat4u copied to clipboard

在个别微信帐号中,调用friendList获取用户列表时错误

Open vzhouzongyu opened this issue 8 years ago • 2 comments

A帐号调用 friendList方法时正常,但B帐号调用时却报发现 TypeError: Cannot read property 'UserName' of undefined错误; 定位到getDisplayName参数中的contact为undefined,临时加了一个判断。但不清楚为什么A帐号不报错,B帐号却报错。。。

export function getDisplayName (contact) {
  if(!contact || !contact.UserName) return '未知用户';

  if (isRoomContact(contact)) {
    return '[群] ' + (contact.RemarkName || contact.DisplayName || contact.NickName ||
      `${getDisplayName(contact.MemberList[0])}、${getDisplayName(contact.MemberList[1])}`)
  } else {
    return contact.DisplayName || contact.RemarkName || contact.NickName || contact.UserName
  }
}

vzhouzongyu avatar May 03 '17 11:05 vzhouzongyu

你可以暂时不用friendList么,这是很早之前写的没有更新过

spacelan avatar May 03 '17 12:05 spacelan

我也有这个问题。

hdwong avatar May 05 '17 06:05 hdwong