组件递归:组件内部调用组件自身
细节:不能在当前组件中使用import+components的方式引入自身并注册来使用
Unknown custom element: <hmCommentItem> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
翻译:未知的用户元素hmCommentItem,你有没有正确的注册这个组件呀?如果是为了递归,确保你提供了name选项
启发:如果想使用组件递归,则必须为组件设置name属性,这个name属性的值就可以当成组件来使用
为组件设置name属性
name: 'recursiveCom',
使用组件递归
需要进行判断,因为不是每个评论对象都会有parent属性
<!-- 使用组件递归 -->
<recursiveCom v-if='comment.parent'
:comment='comment.parent'></recursiveCom>