2019-09-28 18:50:56 +08:00
|
|
|
# Basic
|
2020-01-30 18:48:38 +08:00
|
|
|
Use `$NConfirm` to create a confirm modal.
|
2019-09-28 18:50:56 +08:00
|
|
|
```html
|
|
|
|
<n-button @click="handleConfirm">
|
|
|
|
Confirm
|
|
|
|
</n-button>
|
|
|
|
<n-button @click="handleSuccess">
|
|
|
|
Success
|
|
|
|
</n-button>
|
|
|
|
<n-button @click="handleError">
|
|
|
|
Error
|
|
|
|
</n-button>
|
|
|
|
```
|
|
|
|
```css
|
|
|
|
.n-button {
|
|
|
|
margin: 0 12px 8px 0;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```js
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
handleConfirm (e) {
|
2020-01-30 18:48:38 +08:00
|
|
|
const confirmInstance = this.$NConfirm.warning({
|
|
|
|
title: 'Confirm',
|
2020-02-04 13:23:36 +08:00
|
|
|
content: 'Are you sure?',
|
2020-02-05 23:49:59 +08:00
|
|
|
positiveText: 'Sure',
|
|
|
|
negativeText: 'Not Sure',
|
2019-09-28 18:50:56 +08:00
|
|
|
onPositiveClick: (hide) => {
|
2020-02-04 13:23:36 +08:00
|
|
|
this.$NMessage.success('Sure')
|
2019-09-28 18:50:56 +08:00
|
|
|
hide()
|
|
|
|
},
|
|
|
|
onNegativeClick: (hide) => {
|
2020-02-04 13:23:36 +08:00
|
|
|
this.$NMessage.error('Not Sure')
|
2019-09-28 18:50:56 +08:00
|
|
|
hide()
|
|
|
|
}
|
2020-01-30 18:48:38 +08:00
|
|
|
})
|
2019-09-28 18:50:56 +08:00
|
|
|
},
|
|
|
|
handleSuccess (e) {
|
2019-12-13 18:19:46 +08:00
|
|
|
const confirmInstance = this.$NConfirm.success({
|
2020-01-30 18:48:38 +08:00
|
|
|
title: 'Success',
|
2019-09-28 18:50:56 +08:00
|
|
|
content:
|
2020-02-04 13:23:36 +08:00
|
|
|
'Cool',
|
2020-02-05 23:49:59 +08:00
|
|
|
positiveText: 'Wow!',
|
2019-09-28 18:50:56 +08:00
|
|
|
onPositiveClick: (hide) => {
|
2020-02-04 13:23:36 +08:00
|
|
|
this.$NMessage.success('Great!')
|
2019-09-28 18:50:56 +08:00
|
|
|
hide()
|
|
|
|
}
|
2020-01-30 18:48:38 +08:00
|
|
|
})
|
2019-09-28 18:50:56 +08:00
|
|
|
},
|
|
|
|
handleError(e) {
|
2019-12-13 18:19:46 +08:00
|
|
|
const confirmInstance = this.$NConfirm.error({
|
2020-01-30 18:48:38 +08:00
|
|
|
title: 'Error',
|
2020-02-04 13:23:36 +08:00
|
|
|
content: 'A mistake.',
|
2020-02-05 23:49:59 +08:00
|
|
|
positiveText: 'Ahhh!',
|
2019-09-28 18:50:56 +08:00
|
|
|
onPositiveClick: (hide) => {
|
2020-02-04 13:23:36 +08:00
|
|
|
this.$NMessage.success('I knew it...')
|
2019-09-28 18:50:56 +08:00
|
|
|
hide()
|
|
|
|
}
|
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-09-28 18:50:56 +08:00
|
|
|
```
|