mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-16 01:40:53 +08:00
commit
a4aed820ad
@ -63,12 +63,14 @@ export class Tpl extends React.Component<TplProps, TplState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dom: any;
|
dom: any;
|
||||||
|
mounted: boolean;
|
||||||
|
|
||||||
constructor(props: TplProps) {
|
constructor(props: TplProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
content: this.getContent()
|
content: this.getContent()
|
||||||
};
|
};
|
||||||
|
this.mounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: Readonly<TplProps>): void {
|
componentDidUpdate(prevProps: Readonly<TplProps>): void {
|
||||||
@ -85,13 +87,17 @@ export class Tpl extends React.Component<TplProps, TplState> {
|
|||||||
this.updateContent();
|
this.updateContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.mounted = false;
|
||||||
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
updateContent() {
|
updateContent() {
|
||||||
const {tpl, html, text} = this.props;
|
const {tpl, html, text} = this.props;
|
||||||
|
|
||||||
if (html || tpl || text) {
|
if (html || tpl || text) {
|
||||||
this.getAsyncContent().then(content => {
|
this.getAsyncContent().then(content => {
|
||||||
this.setState({content});
|
this.mounted && this.setState({content});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user