Skip to content

Instantly share code, notes, and snippets.

@uekkie
Forked from ZainWWF/ModalExample.vue
Last active October 22, 2021 12:24
Show Gist options
  • Save uekkie/61377355a6b197cb1796de106ed4aed1 to your computer and use it in GitHub Desktop.
Save uekkie/61377355a6b197cb1796de106ed4aed1 to your computer and use it in GitHub Desktop.
Vue Example for Bootstrap Modal - Composition API
<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