web-interview
web-interview copied to clipboard
[vue] 8.vue slot是做什么的?
trafficstars
答案:主要是让组件的可扩展性更强,简单点说就是,能够在组件内写其他内容
插槽? 插孔???
// CompOne组件创建时候
<slot name="header"></slot>
<slot name="body"></slot>
// 组件使用的时候
<comp-one> <span slot="header"> this is header</span> // 对应CompOne件中的位置 <span slot="body"> this is body</span> //对应CompOne件中的位置 </comp-one>