mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-01 19:38:16 +08:00
chore: tpl 初始用同步模版渲染后更新异步模版
This commit is contained in:
parent
17e32ce204
commit
bfedae3165
@ -68,7 +68,7 @@ export class Tpl extends React.Component<TplProps, TplState> {
|
||||
constructor(props: TplProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
content: ''
|
||||
content: this.getContent()
|
||||
};
|
||||
this.mounted = true;
|
||||
}
|
||||
@ -97,27 +97,27 @@ export class Tpl extends React.Component<TplProps, TplState> {
|
||||
this.mounted && this.setState({content});
|
||||
}
|
||||
|
||||
// @autobind
|
||||
// getContent() {
|
||||
// const {tpl, html, text, raw, data, placeholder} = this.props;
|
||||
// const value = getPropValue(this.props);
|
||||
@autobind
|
||||
getContent() {
|
||||
const {tpl, html, text, raw, data, placeholder} = this.props;
|
||||
const value = getPropValue(this.props);
|
||||
|
||||
// if (raw) {
|
||||
// return raw;
|
||||
// } else if (html) {
|
||||
// return filter(html, data);
|
||||
// } else if (tpl) {
|
||||
// return filter(tpl, data);
|
||||
// } else if (text) {
|
||||
// return escapeHtml(filter(text, data));
|
||||
// } else {
|
||||
// return value == null || value === ''
|
||||
// ? `<span class="text-muted">${placeholder}</span>`
|
||||
// : typeof value === 'string'
|
||||
// ? value
|
||||
// : JSON.stringify(value);
|
||||
// }
|
||||
// }
|
||||
if (raw) {
|
||||
return raw;
|
||||
} else if (html) {
|
||||
return filter(html, data);
|
||||
} else if (tpl) {
|
||||
return filter(tpl, data);
|
||||
} else if (text) {
|
||||
return escapeHtml(filter(text, data));
|
||||
} else {
|
||||
return value == null || value === ''
|
||||
? `<span class="text-muted">${placeholder}</span>`
|
||||
: typeof value === 'string'
|
||||
? value
|
||||
: JSON.stringify(value);
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
async getAsyncContent() {
|
||||
|
Loading…
Reference in New Issue
Block a user