最后

前15.PNG

前16.PNG

由于文档内容过多,为了避免影响到大家的阅读体验,在此只以截图展示部分内容

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

userId: ‘user-9’,

userName: ‘牛九’,

articleId: ‘article-1’,

commentId: ‘comment-10’,

replyId: ‘comment-1’,

desc: ‘钱钟书’,

time: ‘2021-04-05 15:30:25’

},

{

userId: ‘user-5’,

userName: ‘王五’,

articleId: ‘article-2’,

commentId: ‘comment-5’,

replyId: null,

desc: ‘哈哈哈’,

time: ‘2021-04-05 15:30:25’

},

{

userId: ‘user-6’,

userName: ‘张六’,

articleId: ‘article-1’,

commentId: ‘comment-6’,

replyId: ‘comment-4’,

desc: ‘不对吧’,

time: ‘2021-04-05 15:30:25’

},

{

userId: ‘user-7’,

userName: ‘顾七’,

articleId: ‘article-1’,

commentId: ‘comment-7’,

replyId: ‘comment-6’,

desc: ‘对的,就是钱钟书’,

time: ‘2021-04-05 15:30:25’

},

{

userId: ‘user-8’,

userName: ‘朱八’,

articleId: ‘article-3’,

commentId: ‘comment-8’,

replyId: null,

desc: ‘这本书真不错’,

time: ‘2021-04-05 15:30:25’

},

{

userId: ‘user-9’,

userName: ‘纪九’,

articleId: ‘article-4’,

commentId: ‘comment-9’,

replyId: null,

desc: ‘真的好看’,

time: ‘2021-04-05 15:30:25’

}

]

}

},

created() {

this.initCommentLists()

this.initArticleLists()

},

methods: {

// 格式化评论数据

initCommentLists() {

this.commentsList.forEach(i => {

this.$set(i, ‘children’, [])

// 将回复该评论的列表放入children中

let filterList = this.commentsList.filter(

j => j.replyId === i.commentId

)

if (filterList.length > 0) {

i.children = filterList

}

})

// 过滤出最高级

this.commentsList = this.commentsList.filter(i => i.replyId === null)

},

// 格式化文章数据

initArticleLists() {

this.articleLists.forEach(i => {

this.$set(i, ‘children’, [])

let filterList = this.commentsList.filter(

j => j.articleId === i.articleId

)

if (filterList.length > 0) {

i.children = filterList

}

})

}

}

}

my-cycle-list组件:

{{ self.userName }} 回复

<span class=“parent-username” @click=“parentClick”

{{ parent.userName }}:</span

{{ self.desc }}

{{ self.time }}

<span class=“self-username” @click=“commentUserNameClick”>

{{ self.userName }}:

{{ self.desc }}

{{ self.time }}

<my-cycle-list

v-for=“(child, index) in self.children”

:self=“child”

:parent=“self”

:key=“index”

v-if=“self.children.length >= flagNum”

class=“view-all”

@click=“viewAll”

{{ !showAll ? 查看全部 ${self.children.length} 条回复 : 收起 ${self.children.length} 条回复}}

GitHub 加速计划 / vu / vue
108
18
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:3 个月前 )
9e887079 [skip ci] 1 年前
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐