File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1
1
<!--
2
2
* @Date: 2021-12-28 21:08:55
3
- * @LastEditTime: 2021-12-29 00:06:10
3
+ * @LastEditTime: 2021-12-29 00:21:41
4
4
* @FilePath: \imooc-blog\components\article-comment-commit\article-comment-commit.vue
5
5
-->
6
6
<template >
@@ -55,18 +55,23 @@ export default {
55
55
uni .showLoading ({
56
56
title: " 加载中" ,
57
57
});
58
- // 异步处理即可
59
- await userArticleComment ({
58
+ // 调用接口, 异步处理即可
59
+ const { data : res } = await userArticleComment ({
60
60
articleId: this .articleId ,
61
61
content: this .value ,
62
62
});
63
+ console .log (
64
+ " 🚀 ~ file: article-comment-commit.vue ~ line 63 ~ onBtnClick ~ res" ,
65
+ res
66
+ );
67
+ // 发表评论完成之后,给用户一个提示
63
68
uni .showToast ({
64
69
title: " 发表成功" ,
65
70
icon: " success" ,
66
71
mask: true ,
67
72
});
68
- // 发表成功之后的回调
69
- this .$emit (" success" );
73
+ // 发表成功之后的回调:关闭 popup
74
+ this .$emit (" success" , res );
70
75
},
71
76
},
72
77
};
Original file line number Diff line number Diff line change 1
1
<!--
2
2
* @Date: 2021-12-26 18:59:11
3
- * @LastEditTime: 2021-12-26 21:25:41
3
+ * @LastEditTime: 2021-12-29 00:23:27
4
4
* @FilePath: \imooc-blog\components\article-comment-list\article-comment-list.vue
5
5
-->
6
6
<template >
@@ -135,6 +135,12 @@ export default {
135
135
}
136
136
return this .mescroll ;
137
137
},
138
+ /**
139
+ * 为 commentList 增加一个评论
140
+ */
141
+ addCommentList (data ) {
142
+ this .commentList .unshift (data);
143
+ },
138
144
},
139
145
};
140
146
</script >
Original file line number Diff line number Diff line change 1
1
<!--
2
2
* @Date: 2021-12-25 14:04:11
3
- * @LastEditTime: 2021-12-29 00:07:22
3
+ * @LastEditTime: 2021-12-29 00:26:20
4
4
* @FilePath: \imooc-blog\subpkg\pages\blog-detail\blog-detail.vue
5
5
-->
6
6
<template >
@@ -204,10 +204,12 @@ export default {
204
204
/**
205
205
* 发表评论成功
206
206
*/
207
- onSendSuccess () {
207
+ onSendSuccess (data ) {
208
208
// 关闭弹出层
209
209
this .$refs .popup .close ();
210
210
this .isShowCommit = false ;
211
+ // 显示评论数据
212
+ this .$refs .mescrollItem .addCommentList (data);
211
213
},
212
214
},
213
215
};
You can’t perform that action at this time.
0 commit comments