naive-ui/demo/documentation/components/confirm/enUS/async.demo.md
07akioni 487001d697 build: add changelog to site, refactor loader based on suffix
.demo.md for component demo
.demo-entry.md for demo entry
.md for common docs
2020-08-19 23:30:04 +08:00

627 B

Async

Confirm can be async.

<n-button @click="handleClick">
  Success
</n-button>
.n-button {
  margin: 0 12px 8px 0;
}
export default {
  methods: {
    handleClick(e) {
      const confirmInstance = this.$NConfirm.success({
        title: 'Async',
        content:
          'Click and count down 3 second',
        positiveText: 'Confirm',
        onPositiveClick: () => {
          confirmInstance.loading = true
          this.$NMessage.success('Count down 3 second')
          return new Promise(resolve => window.setTimeout(() => resolve(true), 3000))
        }
      })
    }
  }
}