From 4a65a80b4019c09534703e45ce182b8167e5056a Mon Sep 17 00:00:00 2001 From: jhynsoo Date: Thu, 23 May 2024 15:21:39 +0900 Subject: [PATCH] Feat: Add comment write --- src/components/article/ArticleList.vue | 23 +++++++++++++---------- src/components/article/CommentArea.vue | 11 +++++++++-- src/components/article/CommentForm.vue | 8 ++++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/article/ArticleList.vue b/src/components/article/ArticleList.vue index 6fe17ed..6f3fd85 100644 --- a/src/components/article/ArticleList.vue +++ b/src/components/article/ArticleList.vue @@ -1,18 +1,20 @@ diff --git a/src/components/article/CommentForm.vue b/src/components/article/CommentForm.vue index daebeb7..2462d4a 100644 --- a/src/components/article/CommentForm.vue +++ b/src/components/article/CommentForm.vue @@ -4,7 +4,8 @@ import FilledButton from '../common/FilledButton.vue'; import TextButton from '../common/TextButton.vue'; import { addComment } from '@/api/comment'; -const { id } = defineProps({ id: Number }); +const emit = defineEmits(['updateList']); +const { articleId } = defineProps({ articleId: Number }); const isActive = ref(false); const textDiv = ref(null); const text = ref(''); @@ -19,9 +20,8 @@ function handleCancel() { } function handleSubmit() { - addComment({ id, text: text.value }).then(({ data }) => { - console.log(data); - // TODO: 댓글 추가 후 처리 + addComment({ articleId, text: text.value }).then(({ data }) => { + emit('updateList', data); }); text.value = ''; isActive.value = false;