插槽(slot),是组件的一块HTML模板,这块模板显示不显示,怎么显示由父组件来决定。
为什么需要slot-scope 因为子组件有时候需要把data传递给父组件
比如一个表格组件 我们把Ajax请求而来的数据传递给Table组件 但是有需要我们需要自定义内容 自定义的内容需要展示不同的数据 这时候需要对应的data-item 这个data-item在哪里可以获取得到的 就是Table组件内部 所以这时候父组件需要从子组件获取数据
<template><div class="father"><h3>这里是父组件</h3><!--第一次使用:用flex展示数据--><child><template slot-scope="user"><div class="tmpl"><span v-for="item in user.data">{{item}}</span></div></template></child><!--第二次使用:用列表展示数据--><child><template slot-scope="user"><ul><li v-for="item in user.data">{{item}}</li></ul></template></child><!--第三次使用:直接显示数据--><child><template slot-scope="user">{{user.data}}</template></child><!--第四次使用:不使用其提供的数据, 作用域插槽退变成匿名插槽--><child>我就是模板</child></div></template>
- v-slot 替代 slot slot-scope这些属性
slot-scope 子组件把数据交给父组件
插槽组件
和 插槽属性 slot slot-scope 还是不同的

https://github.com/vuejs/rfcs/blob/master/active-rfcs/0001-new-slot-syntax.md
这个rfc提案说的是
<foo><template slot-scope="{ msg }"><div>{{ msg }}</div></template></foo>
When we first introduced scoped slots, it was verbose because it required always using :
每次使用slot-socpe都要声明一个template 挺繁琐的 后面可以不用包裹一层template ,但是会造成映射不清楚 <foo>
<bar slot-scope="{ msg }">
{{ msg }}
</bar>
</foo>
However, the above usage leads to a problem: the placement of slot-scope doesn’t always clearly reflect which component is actually providing the scope variable. Here slot-scope is placed on the
意思是这个msg是提供给foo组件的 不是bar组件的
