How to use a button to show the modal in other components? For example, I have the following components:
info.vue
According to your snippet, you're using a classic Bootstrap modal. You just need to use data-toggle
and data-target
attributes in that case:
I misread the question so i edit my answer.
It's possible to open the modal with a custom method. You just need to find the element "#exampleModal" by using refs
and then open the modal with a bootstrap method (Bootstrap Programmatic API)
methods: {
showModal() {
let element = this.$refs.modal.$el
$(element).modal('show')
}
}
Fiddle example