vue-slot

作者: 王三皮儿 | 来源:发表于2020-01-20 13:57 被阅读0次
父组件
<template>
  <div>
    我是父组件
    <child>
      <p>我是默认插槽</p>
      <template slot="header">
          <p>我是name为header的插槽</p>
      </template>
      <p slot="footer">我是name为footer的插槽</p>
    </child>
  </div>
</template>
子组件
<template>
  <div class="child">
    <div>slottwo</div>
    <slot name="header"></slot>
    <slot></slot>
    <slot name="footer"></slot>
  </div>
</template>

相关文章

  • vue-slot

    父组件 子组件

  • vue-slot

    从官网上我们可以获知,Vue中的slot主要分为:单个插槽、具名插槽和作用域插槽三种。而其使用也较为简单,比如我们...

  • Vue-slot使用方法

    单个 Slot在子组件内使用特殊的 元素就可以为这个子组件添加一个 slot (插槽),在父组件模板里,插入在子组...

  • Vue-slot插槽的使用

    1. 无名插槽: 直接写需要插入的内容即可,内容将会插入到 所有 无名插槽中。 html中: 2. 具名插槽: 需...

网友评论

      本文标题:vue-slot

      本文链接:https://www.haomeiwen.com/subject/hyejzctx.html