Commit 7a811d04 by lijiabin

【需求 25171】fix: 文章详情页等详情返回后再渲染评论区,修复 type 为 undefined 的 prop 警告

parent 0be8205c
......@@ -12,6 +12,7 @@
<!-- 评论区 -->
<Comment
v-if="articleDetail.type"
class="mt-6"
ref="commentRef"
:id="id"
......@@ -41,16 +42,18 @@ const initialCommentId = Number(route.query.commentId) || 0
const articleDetail = ref({} as ArticleItemDto)
const initPage = () => {
Promise.allSettled([getArticleDetail(id)]).then(([r1]) => {
Promise.allSettled([getArticleDetail(id)]).then(async ([r1]) => {
if (r1.status === 'fulfilled') {
articleDetail.value = r1.value.data
// 评论区要等文章详情(拿到 type)回来才渲染,所以定位也放到渲染之后
await nextTick()
if (initialCommentId) {
commentRef.value?.locateComment(initialCommentId)
}
}
})
}
onMounted(async () => {
onMounted(() => {
initPage()
if (initialCommentId) {
commentRef.value?.locateComment(initialCommentId)
}
})
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment