Currently facing a challenge in implementing the modal closure functionality within the Vue.js template.
Take a look at the code snippet:
var modalInstance = new Vue({
el: "#modalInstance",
data: {
displayModal: false
}
});
Vue.component("myCustomModal",
{
template: `
<button class="button" @click="showModal=false">Close</button>
`
});
export default modalInstance;
Check out the corresponding HTML:
<div id="modalInstance">
<myCustomModal v-show="displayModal"></myCustomModal>
<button @click="displayModal = true" class="button is-info">Open Modal</button>
</div>
Essentially, the modal opening is functioning as expected. However, the issue lies in closing the modal triggered within the template in the .js file. It generates an error message stating:
Property or method "displayModal" is not defined on the instance but referenced during render. Ensure that this property is reactive, either in the data option, or for class-based components, by initializing the property.