<script>
export default {
name: 'appTable',
// 接收的prop数据
props: {
data: {
type: Array,
default: () => {
return [];
},
},
columns: {},
operations: {},
isOperations: {},
tableAttrs: {},
},
data() {
return {
loadingMap: {},
};
},
//reder(h){
//第一个参数接收{String | Object | Function},用作元素名字
//第二个参数接收'Object',用作渲染元素属性
//第三个参数接收{String | Array},用作子节点渲染
}
// 在render里每个h()会产生一个vnode节点
render(h) {
const columns = [];
columns.push(h(
'el-table-column',
{
attrs: {
label: '操作',
'min-width': '100px',
align: 'center',
},
// scopedSlots显示props数据,通过default函数获取父节点的data数据
scopedSlots: {
default: props => h('div', props.row.id,console.log(props))
},
}),
h(
'el-table-column',
{
attrs: {
label: '操作',
'min-width': '100px',
align: 'center',
},
},
),
);
return h(
'el-table',
{
// 节点属性
attrs: {
stripe: true,
'highlight-current-row': true,
},
//该h()节点里接收的数据
props: {
data: this.data,
},
},
// 子节点
columns,
);
},
};
</script>
Vue2的render函数使用
最新推荐文章于 2025-06-19 10:07:10 发布