相同点:
它们都是 VUE 提供的用来获取当前作用域内容的。
不同点:
在 2.6.0 中,vue 官方为具名插槽和作用域插槽引入了一个新的统一的语法 (即 v-slot 指令)。它取代了 slot 和 slot-scope。
也就是说如果你 vue 的版本是2.6.0+ 的就要使用 v-slot
下面我来介绍具体使用上的区别
- slot,slot-scope
<template slot="order" slot-scope="scope"><!-- 这里也可以简写为 #order='scope' -->
<el-tag size="mini" v-if="scope.row.cat_level === 0">一级</el-tag>
<el-tag type="success" size="mini" v-else-if="scope.row.cat_level === 1">二级</el-tag>
</template>
- v-slot
<template v-slot:order="scope"><!-- 这里也可以简写为 #order='scope' -->
<el-tag size="mini" v-if="scope.row.cat_level === 0">一级</el-tag>
<el-tag type="success" size="mini" v-else-if="scope.row.cat_level === 1">二级</el-tag>
</template>
上述代码实现的效果一样
注意:‘order’ 是自定义的插槽名字
关于插槽的深入理解 请参考官网:https://cn.vuejs.org/v2/guide/components-slots.html