提交 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,30 +93,35 @@ export class Notice {
* @returns {Promise<any>}
* @memberof Notice
*/
public async confirm(title: string, message: string): Promise<boolean> {
return new Promise(async (resolve, reject) => {
const alert = await alertController.create({
header: title ? title : '标题',
message: message,
buttons: [
{
text: '取消',
handler: () => {
resolve(false);
}
},
{
text: '确认',
cssClass: 'secondary',
handler: () => {
resolve(true);
}
},
],
});
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 : '标题',
message: message,
buttons: [
{
text: '取消',
handler: () => {
store.commit('changeHasClose',true);
resolve(false);
}
},
{
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册