在组件中引入另一组件

组件化开发,最重要的特点就是其复用性。当某一部分内容重复出现在多个组件中
时,可以将其提出单独组成一个组件。重复使用。如下图:其中底部导航条的部分
就会出现在多个组件中

组件引入另一组件

在当前组件card.vue中引入barBottom.vue的步骤如下:

  1. 在card.vue中引入barBottom.vue:
    import barBottom from './barBottom.vue'
  2. 在card.vue的components属性中声明此组件:
components:{
      barBottom,
  }
  1. 在card.vue中使用该组件:
<div class="bottom">
        <bar-bottom></bar-bottom>
</div>

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-05-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案