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;
|
||||
confirmBtnLevel?: string;
|
||||
alertBtnLevel?: string;
|
||||
isolate?: boolean;
|
||||
}
|
||||
|
||||
export interface AlertState {
|
||||
@ -54,6 +55,7 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
content: '',
|
||||
confirm: false
|
||||
};
|
||||
originInstance: Alert | null;
|
||||
constructor(props: AlertProps) {
|
||||
super(props);
|
||||
|
||||
@ -64,8 +66,11 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
||||
this.scopeRef = this.scopeRef.bind(this);
|
||||
|
||||
if (!props.isolate) {
|
||||
this.originInstance = Alert.instance;
|
||||
Alert.instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
confirmText: 'confirm',
|
||||
@ -86,7 +91,10 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Alert.instance = null;
|
||||
if (Alert.instance === this) {
|
||||
Alert.instance = this.originInstance || null;
|
||||
this.originInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
schemaSope: any;
|
||||
|
Loading…
Reference in New Issue
Block a user