具名插槽的使用


 
定义插槽组件
 
创建一个组件
navlot.vue
书写插槽
<template>
  <div class="nav">
    <div class="left">
      <slot name="left"></slot>
    </div>
    <div class="center">
      <slot name="center"></slot>
    </div>
    <div class="right">
      <slot name="right"></slot>
    </div>
  </div>
</template>
slot命名
使用时

 引入

import navslot from '@/components/nav/navslot'
    components:{
                navslot
              },
 
使用
   <navslot class="navs">
      <div class="left" slot="left">
       
      </div>
      <div slot="center">
 
      </div>
      <div slot="right">
          <van-icon name="more" size="40px" />
      </div>
    </navslot>

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM