mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
1.3 KiB
1.3 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: (hide) => {
this.$NMessage.success('Sure')
hide()
},
onNegativeClick: (hide) => {
this.$NMessage.error('Not Sure')
hide()
}
})
},
handleSuccess (e) {
const confirmInstance = this.$NConfirm.success({
title: 'Success',
content:
'Cool',
positiveText: 'Wow!',
onPositiveClick: (hide) => {
this.$NMessage.success('Great!')
hide()
}
})
},
handleError(e) {
const confirmInstance = this.$NConfirm.error({
title: 'Error',
content: 'A mistake.',
positiveText: 'Ahhh!',
onPositiveClick: (hide) => {
this.$NMessage.success('I knew it...')
hide()
}
})
}
}
}