2019-09-28 18:50:56 +08:00
|
|
|
# Async
|
2020-01-30 23:35:57 +08:00
|
|
|
Confirm can be async.
|
2019-09-28 18:50:56 +08:00
|
|
|
```html
|
|
|
|
<n-button @click="handleClick">
|
|
|
|
Success
|
|
|
|
</n-button>
|
|
|
|
```
|
2019-10-21 18:20:00 +08:00
|
|
|
|
2019-09-28 18:50:56 +08:00
|
|
|
```css
|
|
|
|
.n-button {
|
|
|
|
margin: 0 12px 8px 0;
|
|
|
|
}
|
|
|
|
```
|
2019-10-21 18:20:00 +08:00
|
|
|
|
2019-09-28 18:50:56 +08:00
|
|
|
```js
|
|
|
|
export default {
|
|
|
|
methods: {
|
2019-10-21 18:20:00 +08:00
|
|
|
handleClick(e) {
|
2019-12-13 18:19:46 +08:00
|
|
|
const confirmInstance = this.$NConfirm.success({
|
2020-02-04 13:23:36 +08:00
|
|
|
title: 'Async',
|
2019-09-28 18:50:56 +08:00
|
|
|
content:
|
2020-02-04 13:23:36 +08:00
|
|
|
'Click and count down 3 second',
|
2020-02-05 23:49:59 +08:00
|
|
|
positiveText: 'Confirm',
|
2020-03-12 21:32:47 +08:00
|
|
|
onPositiveClick: () => {
|
2020-01-30 18:48:38 +08:00
|
|
|
confirmInstance.loading = true
|
2020-02-04 13:23:36 +08:00
|
|
|
this.$NMessage.success('Count down 3 second')
|
2020-03-12 21:32:47 +08:00
|
|
|
return new Promise(resolve => window.setTimeout(() => resolve(true), 3000))
|
2019-09-28 18:50:56 +08:00
|
|
|
}
|
2020-01-30 18:48:38 +08:00
|
|
|
})
|
2019-09-28 18:50:56 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 18:48:38 +08:00
|
|
|
}
|
2019-10-21 18:20:00 +08:00
|
|
|
```
|