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

[vue] 说说你对slot的理解有多少?slot使用场景有哪些? #431

Open
haizhilin2013 opened this issue Jun 22, 2019 · 4 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 说说你对slot的理解有多少?slot使用场景有哪些?

@haizhilin2013 haizhilin2013 added the vue vue label Jun 22, 2019
@wenyejie
Copy link

slot, 插槽, 在使用组件的时候, 在组建内部插入东西.
组件封装的时候最常使用到

@qq-radio
Copy link

qq-radio commented Jan 1, 2021

通过插槽可以让用户可以拓展组件,去更好地复用组件和对其做定制化处理

如果父组件在使用到一个复用组件的时候,获取这个组件在不同地方有少量的更改,如果去重写组件是一件不明智的事情

通过slot插槽向组件内部指定位置传递内容,完成这个复用组件在不同场景的应用

比如布局组件、表格列、下拉选、弹框显示内容等
ps:来自https://blog.csdn.net/webblock/article/details/111309987

@zhuyu1220
Copy link

props作用是让父组件传递给子组件数据,slot作用是让父组件传递给组件内容.
slot标签上面可以添加name属性,目的是为了可以有多个插槽
插槽作用域 可以让父组件中访问到子组件中的数据

@sc950828
Copy link

默认插槽、具名插槽、作用域插槽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

5 participants