浏览代码

修复评论bug

wkw 3 周之前
父节点
当前提交
f16d5acc3b
共有 2 个文件被更改,包括 13 次插入8 次删除
  1. 13 7
      src/views/im/components/Discover/Discover.vue
  2. 0 1
      src/views/im/components/remarkList/index.vue

+ 13 - 7
src/views/im/components/Discover/Discover.vue

@@ -86,7 +86,7 @@
                 </div>
 
                 <!-- 评论静态数据 -->
-                <Remark v-if="item.commnet_array.length > 0"
+                <Remark
                   ref="remarkRefs"
                   :comments="item.commnet_array"
                   :dynamic-id="item.dynamic_id"
@@ -105,7 +105,7 @@
 <script>
 import { dynamicList, dynamicLike,dynamicDetail } from "@/api/path/im.api";
 import { showToast, showImagePreview } from 'vant';
-import Remark from '../../components/remarkList/index.vue';
+import Remark from '../remarkList/index.vue';
 
 export default {
   components: { Remark },
@@ -194,12 +194,18 @@ export default {
       }
     },
     // 评论
-    handleComment(i,item) {
+    handleComment(i, item) {
       this.showActionsMap[i] = false;
-      const comp = this.$refs.remarkRefs[i];
-      if (comp && comp.openComment) {
-        comp.openComment({ user_id: item.user_id, dynamic_id: item.dynamic_id });
-      }
+      this.$nextTick(() => {
+        const refs = this.$refs.remarkRefs;
+        const comp = Array.isArray(refs) ? refs[i] : refs;
+
+        if (comp && comp.openComment) {
+          comp.openComment({ user_id: item.user_id, dynamic_id: item.dynamic_id });
+        } else {
+          console.warn("Remark 组件未挂载或 openComment 方法不存在", i, refs);
+        }
+      });
     },
     // 更新指定动态的点赞列表
     async setLike(index,dynamic_id){

+ 0 - 1
src/views/im/components/remarkList/index.vue

@@ -89,7 +89,6 @@ export default {
     },
     // 点击评论或回复
     onCommentClick(item) {
-      console.log(item)
       const userWalletId = this.systemStore.USERID;
       if (item.send_user_id === userWalletId) return; // 可实现删除
       this.par.dynamic_id = this.dynamicId;