Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slot的文档希望再详细一点 #291

Open
xmsz opened this issue Jan 31, 2021 · 5 comments
Open

slot的文档希望再详细一点 #291

xmsz opened this issue Jan 31, 2021 · 5 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@xmsz
Copy link

xmsz commented Jan 31, 2021

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

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

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

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

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


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

@ysinsane
Copy link

同感。

@Amour1688 Amour1688 added the help wanted Extra attention is needed label Feb 24, 2021
@github-actions
Copy link

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!

@Tarrowren
Copy link

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

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

@sendya
Copy link

sendya commented May 8, 2021

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

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

@kx59717
Copy link

kx59717 commented May 12, 2021

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

@haoqunjiang haoqunjiang added the documentation Improvements or additions to documentation label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants