index.vue 670 Bytes
<script>
import { ref } from '../utils/vnode';

export default {
  name: 'SchemaTable',
  functional: true,
  render(h, context) {
    const props = context.props || {};
    // 当前函数式组件特有props
    const schema = props.schema;
    // 解析schema参数,设置到即将生成的组件上下文中
    context.props.columns = props.schema.items;
    context.props = Object.assign(context.props, schema.props);
    context.listeners = Object.assign(context.listeners, schema.on);
    // 渲染组件时移除当前组件特有的props,避免透传不必要的参数
    delete context.props.schema;
    return ref('z-table', context);
  },
};
</script>