vue code snippet
  • vue code snippet
  • Vue code snippet
    • 在函数式组件的render函数中透传slot
    • 把父组件的slot传给子组件
    • refs支持响应式编程
  • JS code snippet
    • 用a标签触发下载
Powered by GitBook
On this page
  • 通用写法
  • 传入指定的slot,并重命名

Was this helpful?

  1. Vue code snippet

把父组件的slot传给子组件

Previous在函数式组件的render函数中透传slotNextrefs支持响应式编程

Last updated 2 years ago

Was this helpful?

通用写法

<slot v-for="(_, name) in $slots" :name="name" :slot="name" />
<template v-for="(_, name) in $scopedSlots" :slot="name" slot-scope="slotData">
  <slot :name="name" v-bind="slotData" />
</template>

原文地址:

传入指定的slot,并重命名

<slot name="append-outer" slot="append"/>

append-outer是在父组件指定的slot名,append是子组件里指定的slot名。

Vue: Pass Slots through from Parent to Child Components