Skip to content

Commit ae7ca8f

Browse files
committed
文章操作 - 回显评论数据
1 parent a97e37f commit ae7ca8f

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

project/imooc-blog/components/article-comment-commit/article-comment-commit.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
* @Date: 2021-12-28 21:08:55
3-
* @LastEditTime: 2021-12-29 00:06:10
3+
* @LastEditTime: 2021-12-29 00:21:41
44
* @FilePath: \imooc-blog\components\article-comment-commit\article-comment-commit.vue
55
-->
66
<template>
@@ -55,18 +55,23 @@ export default {
5555
uni.showLoading({
5656
title: "加载中",
5757
});
58-
// 异步处理即可
59-
await userArticleComment({
58+
// 调用接口,异步处理即可
59+
const { data: res } = await userArticleComment({
6060
articleId: this.articleId,
6161
content: this.value,
6262
});
63+
console.log(
64+
"🚀 ~ file: article-comment-commit.vue ~ line 63 ~ onBtnClick ~ res",
65+
res
66+
);
67+
// 发表评论完成之后,给用户一个提示
6368
uni.showToast({
6469
title: "发表成功",
6570
icon: "success",
6671
mask: true,
6772
});
68-
// 发表成功之后的回调
69-
this.$emit("success");
73+
// 发表成功之后的回调:关闭 popup
74+
this.$emit("success", res);
7075
},
7176
},
7277
};

project/imooc-blog/components/article-comment-list/article-comment-list.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
* @Date: 2021-12-26 18:59:11
3-
* @LastEditTime: 2021-12-26 21:25:41
3+
* @LastEditTime: 2021-12-29 00:23:27
44
* @FilePath: \imooc-blog\components\article-comment-list\article-comment-list.vue
55
-->
66
<template>
@@ -135,6 +135,12 @@ export default {
135135
}
136136
return this.mescroll;
137137
},
138+
/**
139+
* 为 commentList 增加一个评论
140+
*/
141+
addCommentList(data) {
142+
this.commentList.unshift(data);
143+
},
138144
},
139145
};
140146
</script>

project/imooc-blog/subpkg/pages/blog-detail/blog-detail.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
* @Date: 2021-12-25 14:04:11
3-
* @LastEditTime: 2021-12-29 00:07:22
3+
* @LastEditTime: 2021-12-29 00:26:20
44
* @FilePath: \imooc-blog\subpkg\pages\blog-detail\blog-detail.vue
55
-->
66
<template>
@@ -204,10 +204,12 @@ export default {
204204
/**
205205
* 发表评论成功
206206
*/
207-
onSendSuccess() {
207+
onSendSuccess(data) {
208208
// 关闭弹出层
209209
this.$refs.popup.close();
210210
this.isShowCommit = false;
211+
// 显示评论数据
212+
this.$refs.mescrollItem.addCommentList(data);
211213
},
212214
},
213215
};

0 commit comments

Comments
 (0)