@alilc/lowcode-rax-renderer
Version:
Rax renderer for Ali lowCode engine
44 lines • 1.93 kB
JavaScript
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
import { componentRendererFactory } from '@alilc/lowcode-renderer-core';
var raxComponentRendererFactory = function () {
var OriginComponent = componentRendererFactory();
return /*#__PURE__*/function (_OriginComponent) {
_inheritsLoose(ComponentRenderer, _OriginComponent);
function ComponentRenderer() {
return _OriginComponent.apply(this, arguments) || this;
}
var _proto = ComponentRenderer.prototype;
_proto.render = function render() {
// @ts-ignore
var that = this;
var _that$props = that.props,
__schema = _that$props.__schema,
__components = _that$props.__components;
if (that.__checkSchema(__schema)) {
return '自定义组件 schema 结构异常!';
}
that.__debug("render - " + __schema.fileName);
var _that$__parseData = that.__parseData(__schema.props),
noContainer = _that$__parseData.noContainer;
var content = that.__renderContextConsumer(function children(context) {
that.context = context;
that.__generateCtx({
component: that
});
that.__render();
// 传 null,使用内置的 div 来渲染,解决在页面中渲染 vc-component 报错的问题
return that.__renderComp(null, {
compContext: that,
blockContext: that
});
});
if (noContainer) {
return content;
}
return that.__renderContent(content);
};
return ComponentRenderer;
}(OriginComponent);
};
export default raxComponentRendererFactory;