繁体   English   中英

Vue 2.6.0-如何使用新的插槽语法将插槽内容呈现给子组件的命名插槽

[英]Vue 2.6.0 - How to use the new slot syntax to render slot content to children component's named slot

要理解我的问题,请看下面的伪代码:

<my-tooltip-wrapper>
  <some-slot-content />
</my-tooltip-wrapper

MyTooltipWrapper包含程序包中的TooltipComponent 但是,这需要另一个广告位来显示我的<some-slot-content />

以使用旧语法的示例为例 ,请看一下并尝试使用新语法。

在更改插槽语法之前,我可以像这样使用它:

//inside of MyTooltipWrapper
<tooltip-component>
   <slot
      name="reference"
      slot="reference"
   />
</tooltip-component>

但是,如何将其更改为新语法? 我试过了,但是没有用:

<template #reference>
  <slot
    name="reference"
  />
</template>

https://jsfiddle.net/a8q09cfh/

<slot-owner>
  <template v-slot:reference>
      Hello world
  </template>
</slot-owner>


Vue.component('slot-owner', {
  template: `
     <div>
        <slot name="reference" />
     </div>
  `
});

在这里有人问类似的问题

它已通过最新的提交修复

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM