**I'm trying to implement submit button logic with a simple empty strings input validation, but after clicking the button the whole window gets epty. While conforming to the if statement one block needs to be displayed.
https://codesandbox.io/s/intelligent-jasper-teh1im?file=/src/components/Button.vue**
<template>
<button class="btn" @click="submit">Submit</button>
</template>
<script>
export default {
inject: [
"firstName",
"lastName",
"paymentAmount",
"accountNumber",
"isFinalStep",
],
data() {
return {
firstName: this.firstName,
lastName: this.lastName,
paymentAmount: this.paymentAmount,
accountNumber: this.accountNumber,
};
},
methods: {
submit() {
if (
!this.firstName &&
!this.lastName &&
!this.paymentAmount &&
!this.accountNumber
) {
this.isFinalStep();
} else {
alert("please fill the required fields");
}
},
},
};
Looks like you just didn't register your
FinalStepcomponent:When I add it in App.vue, it seems to work: