File tree Expand file tree Collapse file tree 2 files changed +28
-15
lines changed
packages/nuxt/playground/components Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import { ModalsContainer , useModal } from ' vue-final-modal'
3- import PlainCssConfirmModal from ' ./PlainCssConfirmModal.vue '
2+ import { ModalsContainer , useVfm } from ' vue-final-modal'
3+ import { showConfirmModal } from ' ./showConfirmModal '
44
5- const { open, close } = useModal ({
6- component: markRaw (PlainCssConfirmModal ),
7- attrs: {
8- title: ' Hello World!' ,
9- onConfirm() {
10- close ()
11- },
12- },
13- slots: {
14- default: ' <p>The content of the modal</p>' ,
15- },
16- })
5+ const vfm = useVfm ()
176 </script >
187
198<template >
20- <button @click =" () => open( )" >
9+ <button @click =" () => showConfirmModal(vfm )" >
2110 Open Modal
2211 </button >
2312
Original file line number Diff line number Diff line change 1+ import type { Vfm } from 'vue-final-modal'
2+ import { useModal } from 'vue-final-modal'
3+ import PlainCssConfirmModal from './PlainCssConfirmModal.vue'
4+
5+ export function showConfirmModal ( vfm : Vfm ) {
6+ const { open, close, destroy } = useModal ( {
7+ context : vfm ,
8+ component : markRaw ( PlainCssConfirmModal ) ,
9+ attrs : {
10+ title : 'Hello World!' ,
11+ onConfirm ( ) {
12+ close ( )
13+ } ,
14+ onClosed ( ) {
15+ destroy ( )
16+ } ,
17+ } ,
18+ slots : {
19+ default : '<p>The content of the modal</p>' ,
20+ } ,
21+ } )
22+
23+ open ( )
24+ }
You can’t perform that action at this time.
0 commit comments