I'm new to Vue.js and I'm working with modals. I'm using the Buefy framework mostly. This is my example code:
<template>
<section>
<button class="button is-primary is-small" @click="addModal = true">
<span>Insert New</span>
</button>
<b-modal :active.sync="addModal"
has-modal-card
trap-focus
:destroy-on-hide="false"
aria-role="dialog"
aria-modal>
<modal-form v-bind="formProps"></modal-form>
</b-modal>
</section>
</template>
<script>
const ModalForm = {
props: ["tagName", "moreFields"],
template: `
<form action="">
<div class="modal-card" style="width: auto">
//input fields here
<footer class="modal-card-foot">
<button class="button" type="button" @click="$parent.close()">Close</button>
<button class="button is-primary" @click="addTag">Add Tag</button>
</footer>
</div>
</form>
`,
};
export default {
components: {
ModalForm,
},
data() {
return {
data: {
tagName: "",
},
addModal: false,
};
},
methods: {
addTag() {
if (this.data.tagName.trim().length > "") {
console.log(mydata);
}
},
},
};
</script>
However, when I try to click the Add Tag button, I get the error Invalid handler for event "click": got undefined...
There seems to be so many issues with this and I didn't want to duplicate a post, but I've searched around the site and mostly people have typo issues (method instead of methods). Would it be because of the scope of the modal? That somehow addTag isnt visible to it?
How would I fix this?