mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
chore: alert 支持多个实例
This commit is contained in:
parent
7035ee73eb
commit
fb89400139
@ -18,6 +18,7 @@ export interface AlertProps extends ThemeProps, LocaleProps {
|
|||||||
title?: string;
|
title?: string;
|
||||||
confirmBtnLevel?: string;
|
confirmBtnLevel?: string;
|
||||||
alertBtnLevel?: string;
|
alertBtnLevel?: string;
|
||||||
|
isolate?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AlertState {
|
export interface AlertState {
|
||||||
@ -54,6 +55,7 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
|||||||
content: '',
|
content: '',
|
||||||
confirm: false
|
confirm: false
|
||||||
};
|
};
|
||||||
|
originInstance: Alert | null;
|
||||||
constructor(props: AlertProps) {
|
constructor(props: AlertProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@ -64,7 +66,10 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
|||||||
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
||||||
this.scopeRef = this.scopeRef.bind(this);
|
this.scopeRef = this.scopeRef.bind(this);
|
||||||
|
|
||||||
Alert.instance = this;
|
if (!props.isolate) {
|
||||||
|
this.originInstance = Alert.instance;
|
||||||
|
Alert.instance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@ -86,7 +91,10 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
Alert.instance = null;
|
if (Alert.instance === this) {
|
||||||
|
Alert.instance = this.originInstance || null;
|
||||||
|
this.originInstance = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
schemaSope: any;
|
schemaSope: any;
|
||||||
|
Loading…
Reference in New Issue
Block a user