babel-plugin-jsx icon indicating copy to clipboard operation
babel-plugin-jsx copied to clipboard

slot的文档希望再详细一点

Open xmsz opened this issue 4 years ago • 5 comments

情况一:没有完整例子 文档中只有定义slots对象,但是在组件里该这么用没说,只能试一遍。感觉如果文档写了,那大可不必

情况二:没有说明默认slot 正常来说默认插槽是很合理的,不过由于可能实现机制问题所以不支持,那希望也说一下,不然一直找,后来才发现么有

情况三:如果不写vSlots而直接使用默认插槽会有坑也没说明

const A = (props,ctx) => <>{ctx.slots.default?.()}</>

const B = () => <A>这是动态的内容</A>


上面代码实际上是能跑的,但是问题是里面的内容如果是动态或者发生了改变是不会触发更新的 这一点和情况二一样如果能提前说明一下会省事很多,当然如果能支持肯定更好,不然太别扭了,传个插槽得先传个对象

xmsz avatar Jan 31 '21 15:01 xmsz

同感。

ysinsane avatar Feb 21 '21 17:02 ysinsane

Hello @xmsz. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please be sure to fill in the default template in the Pull Request, provide changelog/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!

github-actions[bot] avatar Feb 24 '21 05:02 github-actions[bot]

const A = (props, ctx) => <>{ctx.slots.default?.()}</>;

const B = () => (
  <A
    v-slots={{
      default: () => <>...</>,
    }}
  ></A>
);

Tarrowren avatar Mar 03 '21 07:03 Tarrowren

const A = (props, ctx) => ctx.slots.default?.();

const B = () => (
  <A>{(<>...</>)}</A>
);

sendya avatar May 08 '21 08:05 sendya

请问slots如何定义类型哦,比如定义slots只能使用字符串之类的

kx59717 avatar May 12 '21 10:05 kx59717