iview-admin icon indicating copy to clipboard operation
iview-admin copied to clipboard

如何使用Modal调用Modal?

Open lanzehao opened this issue 6 years ago • 2 comments

例如,我在confirm和custom这两个方法中都写了Modal.confirm,但是当我使用confirm的onOk来调用custom时,弹出的custom对话框闪烁一下就消失了,这是为什么呢?**

confirm () {
	this.$Modal.confirm({
		content: '<p>1</p>',
		onOk: () => {
			this.custom();
		}
	});
},
custom () {
	this.$Modal.confirm({
		content: '<p>2</p>',
		okText: 'OK',
		cancelText: 'Cancel'
	});
}

lanzehao avatar Aug 17 '18 06:08 lanzehao

https://github.com/iview/iview/blob/2.0/src/components/modal/modal.vue#L333 源码中settimeout 300毫秒后才关闭

yan170772286 avatar Aug 18 '18 07:08 yan170772286

可以试试这种写法

confirm () { 
  this.$Modal.confirm({ 
    content: '<p>1</p>', 
    onOk: () => { 
      setTimeout(() => { this.custom(); }, 300) 
      this.$Modal.remove()
    }
  }); 
}, 
custom () { 
  this.$Modal.confirm({ 
    content: '<p>2</p>', 
    okText: 'OK', 
    cancelText: 'Cancel'
  }); 
}

ZTao-z avatar Oct 23 '19 11:10 ZTao-z