Skip to content

Instantly share code, notes, and snippets.

@kakha13
Created August 4, 2022 20:52
Show Gist options
  • Save kakha13/03fd5596190de4f19709a8b43fd53eb3 to your computer and use it in GitHub Desktop.
Save kakha13/03fd5596190de4f19709a8b43fd53eb3 to your computer and use it in GitHub Desktop.
Nuxt3 Modal
************* inside main page *************
<template>
<div>
<Modal :open="modalOpen" @update:open="newValue => modalOpen = newValue" />
<button @click="openModal = true">Show Modal</button>
</div>
</template>
<script setup>
const modalOpen = ref(false)
</script>
************* inside Modal component *************
<template>
<div>
<div v-if="open">
<button @click="$emit('update:open', false)">Close</buttom>
<h1>Hello Modal</h1>
</div>
</div>
</template>
<script setup>
defineProps({
open: {
default: false,
type: Boolean,
},
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment