提交 a012b3ed 编写于 作者: zhujiamin's avatar zhujiamin

表单值变更 退出时确认框重复渲染

上级 5dcf7605
import { toastController, alertController } from '@ionic/core';
import { Store } from 'vuex';
/**
* 消息提示
*
......@@ -8,6 +8,11 @@ import { toastController, alertController } from '@ionic/core';
*/
export class Notice {
/**
* store
*/
public store:Store<any> = null;
/**
* 唯一实例
*
......@@ -23,6 +28,7 @@ export class Notice {
* @memberof Notice
*/
constructor() {
this.store = Store;
if (Notice.instance) {
return Notice.instance;
}
......@@ -87,7 +93,7 @@ export class Notice {
* @returns {Promise<any>}
* @memberof Notice
*/
public async confirm(title: string, message: string): Promise<boolean> {
public async confirm(title: string, message: string, store?: Store<any>): Promise<boolean> {
return new Promise(async (resolve, reject) => {
const alert = await alertController.create({
header: title ? title : '标题',
......@@ -96,6 +102,7 @@ export class Notice {
{
text: '取消',
handler: () => {
store.commit('changeHasClose',true);
resolve(false);
}
},
......@@ -103,12 +110,16 @@ export class Notice {
text: '确认',
cssClass: 'secondary',
handler: () => {
store.commit('changeHasClose',true);
resolve(true);
}
},
],
});
if (store.state.hasClose) {
await alert.present();
}
store.commit('changeHasClose',false);
});
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册