tpl 改成渲染到内部 span 上

This commit is contained in:
2betop 2020-09-25 14:14:53 +08:00
parent c0e1e91476
commit 9fc20aa728
3 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,5 @@
.#{$ns}TplField {
&.is-inline {
display: inline;
display: inline-block;
}
}

View File

@ -50,7 +50,7 @@ export class Html extends React.Component<HtmlProps> {
const {html} = this.props;
if (html) {
this.dom.innerHTML = html;
this.dom.firstChild.innerHTML = html;
}
}
@ -60,7 +60,9 @@ export class Html extends React.Component<HtmlProps> {
const Component = wrapperComponent || (inline ? 'span' : 'div');
return (
<Component ref={this.htmlRef} className={cx(`${ns}Html`, className)} />
<Component ref={this.htmlRef} className={cx(`${ns}Html`, className)}>
<span />
</Component>
);
}
}

View File

@ -91,7 +91,7 @@ export class Tpl extends React.Component<TplProps, object> {
return;
}
this.dom.innerHTML = this.getContent();
this.dom.firstChild.innerHTML = this.getContent();
}
render() {
@ -100,10 +100,11 @@ export class Tpl extends React.Component<TplProps, object> {
return (
<Component
children={this.getContent()}
ref={this.htmlRef}
className={cx('TplField', inline ? 'is-inline' : '', className)}
/>
>
<span>{this.getContent()}</span>
</Component>
);
}
}