vue组件中的作用域插槽
插槽<slot>可以在父组件使用子组件时,改变子组件类容。
作用域插槽可以使得父组件页面可以使用子组件的数据:v-slot
v-slot具名插槽使用
<template v-slot:header>
<h1>Here might be a page title</h1>
</template>
相当于
<template slot="header">
<h1>Here might be a page title</h1>
</template>
v-slot作用域插槽使用
<template v-slot:default="slotProps"> {{ slotProps.user.firstName }} </template>
当子组件为默认插槽时可以写为(当被提供的内容只有默认插槽时,组件的标签才可以被当作插槽的模板来使用)
<template v-slot="slotProps">
{{ slotProps.user.firstName }}
</template>
slot-scope:可以获取父组件传递给子组件的数据一般在<tempate>中使用
<el-table :data="btnTableData" style="width: 100%">
<el-table-column prop="menuUses" label="适用对象"> <template slot-scope="scope"> <span v-if="scope.row.menuUses">企业</span> </template> </el-table-column>
</el-table>
浙公网安备 33010602011771号