-
-
Save uekkie/61377355a6b197cb1796de106ed4aed1 to your computer and use it in GitHub Desktop.
Vue Example for Bootstrap Modal - Composition API
This file contains 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
<template> | |
<div> | |
<b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button> | |
<b-modal ref="myModal" hide-footer title="Using Component Methods"> | |
<div class="d-block text-center"> | |
<h3>Hello From My Modal!</h3> | |
</div> | |
<b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button> | |
</b-modal> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { defineComponent, ref } from '@vue/composition-api' | |
export default defineComponent({ | |
components: {}, | |
setup() { | |
myModal = ref() | |
hideModal = () => { | |
myModal.value.hide() | |
} | |
toggleModal = () => { | |
myModal.value.show() | |
} | |
return { | |
myModal, | |
hideModal, | |
toggleModal, | |
} | |
}, | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment