Browse Source

我的动态粉丝搜索报错

zhuli 1 month ago
parent
commit
c06347d633
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/views/dynamicManagement/myDynamic.vue

+ 6 - 6
src/views/dynamicManagement/myDynamic.vue

@@ -879,11 +879,11 @@ const addFriendSearching = ref(false);
 
 // 过滤后的好友列表
 const filteredShareFriendList = computed(() => {
-  if (!shareSearch.value) {
+  if (shareSearch.value == null || shareSearch.value === "") {
     return shareFriendList.value;
   }
-  const keyword = shareSearch.value.toLowerCase();
-  return shareFriendList.value.filter(friend => friend.name.toLowerCase().includes(keyword));
+  const keyword = String(shareSearch.value).toLowerCase();
+  return shareFriendList.value.filter(friend => (friend.name ?? "").toLowerCase().includes(keyword));
 });
 
 // 用户信息
@@ -911,12 +911,12 @@ const relationDialogTitle = computed(() => {
 
 // 过滤后的关系列表
 const filteredRelationList = computed(() => {
-  if (!relationSearch.value) {
+  if (relationSearch.value == null || relationSearch.value === "") {
     return relationList.value;
   }
-  const keyword = relationSearch.value.toLowerCase();
+  const keyword = String(relationSearch.value).toLowerCase();
   return relationList.value.filter(
-    user => user.name.toLowerCase().includes(keyword) || user.description.toLowerCase().includes(keyword)
+    user => (user.name ?? "").toLowerCase().includes(keyword) || (user.description ?? "").toLowerCase().includes(keyword)
   );
 });