Does anyone know a straightforward solution to this issue? I've been struggling to find one.
Within my HTML file, there's a button that looks like this:
<button @click="showModal">Show Modal</button>
By clicking on the button, it triggers the following method:
new Vue({
el: '#root',
methods: {
showModal() { Event.$emit('showModal'); },
}
});
My goal is to toggle a class in a modal component when the button is clicked. Below is part of the component's code relevant to this functionality:
Vue.component('modal', {
template: `
<div :class="[ modalClass, {'is-active' : isActive }]">
ETC...
</div>
`
data() {
return {
isActive: false,
modalClass: 'modal'
}
}
Being new to VueJS, I'm finding it challenging to communicate effectively within Vue. What steps should I take to ensure that isActive becomes true upon clicking the button?
Your input and advice would be greatly appreciated!
Sincerely,
Moshe