slot新语法使用

vue 2.5已淘汰的语法

<base-layout>
  <template slot="header">
    <h1>Here might be a page title</h1>
  </template>

  <p>A paragraph for the main content.</p>
  <p>And another one.</p>

  <template slot="footer">
    <p>Here's some contact info</p>
  </template>
</base-layout>
  <base-layout>
  <h1 slot="header">Here might be a page title</h1>

  <p>A paragraph for the main content.</p>
  <p>And another one.</p>

  <p slot="footer">Here's some contact info</p>
</base-layout>

具名插槽vue 2.6+语法展示(Vue 3支持)

      <template v-slot:item-icon> <!-- 注意和废弃语法slot="header"对比 -->
        <i class="iconfont icon-shouye"></i><!-- v-slot不能直接写在标签上,必须写在template,否则渲染不出来 -->
      </template>
      <template v-slot:item-text><!-- 注意和废弃语法slot="header"对比 -->
        <p>首页</p>
      </template>
    <slot name="item-icon"></slot>
    <slot name="item-text"></slot>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。