vue组件中slot插槽的使用

写一个headerbar组件,里面可以放任何东西

<div ref="headerbarWrapper" class="el-table_headerbar"  v-if="showheaderbar" >
    <slot name="headerbar"></slot>
</div>

组件使用时:

 <template slot="headerbar">
     <hy-button text="新增" size="small" icon="icon-plus" >
     </hy-button> 
     <hy-button type="info" text="查询" size="small" icon="icon-search" >
     </hy-button> 
 </template>

 

posted @ 2020-07-30 08:56  氧化成风  阅读(228)  评论(0编辑  收藏  举报