Vant overlay遮罩层源码

1,018 阅读1分钟

DialogOverlay都在

export default createComponent(Overlay)

这里的createComponent其实是createNamespace返回值数组中的第一项, 这个第一项是下边方法的执行结果

//第一项 createComponent(name)
...
export function createComponent(name) {
  return function (sfc) {
    if (typeof sfc === 'function') {
      sfc = transformFunctionComponent(sfc);
    }

    if (!sfc.functional) {
      sfc.mixins = sfc.mixins || [];
      sfc.mixins.push(SlotsMixin);
    }

    if (sfc.props) {
      defaultProps(sfc.props);
    }

    sfc.name = name;
    sfc.install = install;
    return sfc;
  };
}

也就是说,export default createComponent(Overlay)Overlay就是上边方法中sfc

sfc = transformFunctionComponent(sfc)

function transformFunctionComponent(sfc) {
  return {
    functional: true,
    props: sfc.props,
    model: sfc.model,
    render: function render(h, context) {
      return sfc(h, context.props, unifySlots(context), context);
    }
  };
}