mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 05:48:17 +00:00
feat: 支持全局css
This commit is contained in:
parent
6f290abe91
commit
e371092952
@ -268,9 +268,32 @@ export default function baseRenererFactory() {
|
|||||||
this.setLocale = (loc: string) => this.appHelper?.utils?.i18n?.setLocale && this.appHelper?.utils?.i18n?.setLocale(loc);
|
this.setLocale = (loc: string) => this.appHelper?.utils?.i18n?.setLocale && this.appHelper?.utils?.i18n?.setLocale(loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
__writeCss = () => {
|
||||||
|
const css = getValue(this.props.__schema, 'css', '');
|
||||||
|
let style = this.styleElement;
|
||||||
|
if (!this.styleElement) {
|
||||||
|
style = document.createElement('style');
|
||||||
|
style.type = 'text/css';
|
||||||
|
style.setAttribute('from', 'style-sheet');
|
||||||
|
if (style.firstChild) {
|
||||||
|
style.removeChild(style.firstChild);
|
||||||
|
}
|
||||||
|
const head = document.head || document.getElementsByTagName('head')[0];
|
||||||
|
head.appendChild(style);
|
||||||
|
this.styleElement = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (style.innerHTML === css) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
style.innerHTML = css;
|
||||||
|
};
|
||||||
|
|
||||||
__render = () => {
|
__render = () => {
|
||||||
const schema = this.props.__schema;
|
const schema = this.props.__schema;
|
||||||
this.__setLifeCycleMethods('render');
|
this.__setLifeCycleMethods('render');
|
||||||
|
this.__writeCss();
|
||||||
|
|
||||||
const { engine } = this.context;
|
const { engine } = this.context;
|
||||||
if (engine) {
|
if (engine) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user