naive-ui/demo/documentation/components/confirm/enUS/async.md

34 lines
627 B
Markdown
Raw Normal View History

# Async
2020-01-30 23:35:57 +08:00
Confirm can be async.
```html
<n-button @click="handleClick">
Success
</n-button>
```
2019-10-21 18:20:00 +08:00
```css
.n-button {
margin: 0 12px 8px 0;
}
```
2019-10-21 18:20:00 +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',
content:
2020-02-04 13:23:36 +08:00
'Click and count down 3 second',
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))
}
2020-01-30 18:48:38 +08:00
})
}
}
2020-01-30 18:48:38 +08:00
}
2019-10-21 18:20:00 +08:00
```