博客评论后重加载评论

This commit is contained in:
2024-09-01 15:47:10 +08:00
parent bc062a597b
commit 73c334494f
3 changed files with 16 additions and 5 deletions

View File

@@ -1,8 +1,9 @@
<script setup>
import { request } from '@/lib/request';
import { computed, onMounted, reactive, ref } from 'vue';
import { computed, onMounted, reactive, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { timestampToString } from '@/lib/timestampToString';
const model = defineModel();
const route = useRoute()
const bloguuid = route.params.uuid;
const blogCommentList = reactive([]);
@@ -26,6 +27,7 @@ const loadComment = async () => {
try {
let commentRes = await request.get(`/blogComment?bloguuid=${bloguuid}`);
if (commentRes.code == 0) {
blogCommentList.splice(0, blogCommentList.length);
blogCommentList.push(...commentRes.data);
loadStatus.value = 1;
} else {
@@ -36,6 +38,12 @@ const loadComment = async () => {
loadStatus.value = -1;
}
}
watch(model, (newValue, oldValue) => {
if (newValue) {
loadComment();
}
})
</script>
<template>
<el-divider></el-divider>