Subscribe on changes!

Scoped slot doesn't work with custom component

avatar
Sep 2nd 2020

Version

3.0.0-rc.9

Reproduction link

https://jsfiddle.net/pdqm4kfe/1/

Steps to reproduce

Open jsfiddle

What is expected?

I want to see scoped data in a component

What is actually happening?

I see empty slot

avatar
Sep 2nd 2020

When shorthand syntax is used on the component it is considered to be specifying the slot of that component.

Correct usage:

<my-comp #test="slotProps">
    <my-comp2>
      <span class="green">{{ slotProps.item }}<span>
    </my-comp2>
  </my-comp>

Or, to be more explicit, use a <template>:

<my-comp>
  <template #test="slotProps">
    <my-comp2>
      <span class="green">{{ slotProps.item }}<span>
    </my-comp2>
    </template>
  </my-comp>
avatar
Oct 1st 2020

统一以往的slot-scope和具名插槽,如果需要用到slot-scope的话,后面跟上slotProps,即写成 #test="slotProps就可以了。更方便了,牛逼