Created
August 4, 2022 20:52
-
-
Save kakha13/03fd5596190de4f19709a8b43fd53eb3 to your computer and use it in GitHub Desktop.
Nuxt3 Modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
************* 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