2018-03-07 13:36:15 +00:00
|
|
|
|
|
|
|
<cn>
|
2018-12-09 09:34:27 +00:00
|
|
|
#### 手动更新和移除
|
|
|
|
手动更新和关闭 `Modal.method` 方式创建的对话框。
|
2018-03-07 13:36:15 +00:00
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
2018-12-09 09:34:27 +00:00
|
|
|
#### Manual to update destroy
|
|
|
|
Manually updateing and destroying a modal from `Modal.method`.
|
2018-03-07 13:36:15 +00:00
|
|
|
</us>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<template>
|
2018-12-09 09:34:27 +00:00
|
|
|
<a-button @click="countDown">Open modal to close in 5s</a-button>
|
2018-03-07 13:36:15 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
2018-12-09 09:34:27 +00:00
|
|
|
countDown() {
|
|
|
|
let secondsToGo = 5;
|
2018-04-08 13:17:20 +00:00
|
|
|
const modal = this.$success({
|
2018-03-07 13:36:15 +00:00
|
|
|
title: 'This is a notification message',
|
2018-12-09 09:34:27 +00:00
|
|
|
content: `This modal will be destroyed after ${secondsToGo} second.`,
|
2018-03-07 13:36:15 +00:00
|
|
|
});
|
2018-12-09 09:34:27 +00:00
|
|
|
const interval = setInterval(() => {
|
|
|
|
secondsToGo -= 1;
|
|
|
|
modal.update({
|
|
|
|
content: `This modal will be destroyed after ${secondsToGo} second.`,
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
setTimeout(() => {
|
|
|
|
clearInterval(interval)
|
|
|
|
modal.destroy()
|
|
|
|
}, secondsToGo * 1000);
|
2018-03-07 13:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|