Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A plugin dedicated for vue3 to show confirm dialog modal

License

NotificationsYou must be signed in to change notification settings

malekim/v3confirm

Repository files navigation

codecovsemantic-release

A plugin dedicated for vue3 to show confirm dialog modal. Currently the plugin works only with composition api.

Installation

The plugin can be installed by npm or yarn.

NPM

npm install v3confirm --save

Yarn

yarn add v3confirm

Usage

import{createApp}from'vue'importVueConfirmPluginfrom'v3confirm'importAppfrom'@/App.vue'constapp=createApp(App)app.use(VueConfirmPlugin,{root:'#confirm',yesText:'Yes',noText:'No',})app.mount('#app')

Remember to have a html handler somewhere with id provided in root option. For example in App.vue:

<template><divid="confirm"></div></template>

Then in component with composition api:

<template><button@click="deleteAllUsers"><button@click="deleteAllUsersWithAsync"></template><scriptlang="ts">import{defineComponent}from'vue'import{useConfirm}from'v3confirm'exportdefaultdefineComponent({setup:()=>{constconfirm=useConfirm()constdeleteAllUsers=()=>{confirm.show('Are you sure?').then((ok)=>{if(ok){alert('All users deleted')}else{alert('Users not deleted')}})}constdeleteAllUsersWithAsync=async()=>{constok=awaitconfirm.show('Are you sure?')if(ok){alert('All users deleted')}else{alert('Users not deleted')}}return{        deleteAllUsers,        deleteAllUsersWithAsync,}},})</script>

Options

root

Type: string

Default: none

An HTML element where confirm dialog is attached. It should be empty.

yesText

Type string

Default: 'yes'

A text used for confirm button.

noText

Type string

Default: 'no'

A text used for decline button.

Styles

This project is using bulma.io styles. If your project is not using bulma, then you can style confirm for your own orimport bulma modal.

@import"bulma/sass/utilities/_all.sass"@import"bulma/sass/components/modal.sass"

[8]ページ先頭

©2009-2025 Movatter.jp