需求背景
封装一个带有操作栏的table组件,其中操作栏是插槽,传入各种操作的按钮,点击获取每行的数据
子组件
<template v-if="columnEdit">
<el-table-column :label="columTitle" :width="columnEditWidth ? columnEditWidth : ''" :fixed="columnEditFixed"
align="center">
<template #default="scope">
<slot :row="scope.row" name="EditColumn"></slot>
</template>
</el-table-column>
</template>
父组件
<template v-slot:EditColumn slot-scope="scope">
<div class="tableAction" @click="dataView(scope.row)">查看</div>
</template>
scope row 一直反复报错 拿不到
求教应该如何写
在 vue 3 slot-scope 改成 v-slot 了
https://vuejs.org/guide/components/slots.html#scoped-slots
我拿官方例子试了一下可以拿到值
CTable.vue
App.vue