I'm working on a Vue.js v3 project using the composition API. I have defined a variable in my setup like this:
setup() {
const showInvoiceItemForm = true;
return { showInvoiceItemForm };
},
Now, I want to show a form when a button is clicked and a function is called:
<form @submit.prevent="submit">
<InvoiceItem
:form="form"
v-if="this.showInvoiceItemForm"
></InvoiceItem>
<div class="mt-20 flex flex-row justify-between space-x-8">
<BreezeButton type="button" @click="addInvoiceItem"
>Add Item</BreezeButton
>
<BreezeButton>Generate Invoice</BreezeButton>
</div>
</form>
The method to handle showing the form is as follows:
addInvoiceItem() {
this.showInvoiceItemForm = true;
console.log(this.showInvoiceItemForm);
},
Despite setting the value of showInvoiceItemForm
to true
, the form isn't displayed. It seems that the value doesn't change properly. Can someone provide guidance on how to correctly use the composition API variable?