- 我试图用一个简单的空字符串输入验证来实现提交按钮逻辑,但是在点击按钮之后,整个窗口都变空了。虽然符合if语句,但需要显示一个块。
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");
}
},
},
};
1条答案
按热度按时间jvlzgdj91#
似乎您尚未注册
FinalStep
组件:[Vue警告]:无法解析组件:FinalStep如果这是一个本地自定义元素,请确保通过compilerOptions.isCustomElement.at将其从组件解析中排除
当我在App. vue中添加它时,它似乎起作用了: