mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
1.2 KiB
1.2 KiB
Basic
Use $NConfirm
to create a confirm modal.
<n-button @click="handleConfirm">
Confirm
</n-button>
<n-button @click="handleSuccess">
Success
</n-button>
<n-button @click="handleError">
Error
</n-button>
.n-button {
margin: 0 12px 8px 0;
}
export default {
methods: {
handleConfirm (e) {
const confirmInstance = this.$NConfirm.warning({
title: 'Confirm',
content: 'Are you sure?',
positiveText: 'Sure',
negativeText: 'Not Sure',
onPositiveClick: () => {
this.$NMessage.success('Sure')
},
onNegativeClick: () => {
this.$NMessage.error('Not Sure')
}
})
},
handleSuccess (e) {
const confirmInstance = this.$NConfirm.success({
title: 'Success',
content:
'Cool',
positiveText: 'Wow!',
onPositiveClick: () => {
this.$NMessage.success('Great!')
}
})
},
handleError(e) {
const confirmInstance = this.$NConfirm.error({
title: 'Error',
content: 'A mistake.',
positiveText: 'Ahhh!',
onPositiveClick: () => {
this.$NMessage.success('I knew it...')
}
})
}
}
}