【发布时间】:2019-10-18 05:21:42
【问题描述】:
当我输入电子邮件id 时,仍然通知电子邮件需要错误消息。截图:https://prnt.sc/pkw6ll
我需要输入邮箱id时,不会显示错误信息。
HTML:
<form
class="footer-form"
id="footerform-details"
@submit="checkForm"
action="#"
method="post"
>
<div class="form-group" id="footerbtn-tooltip">
<input
type="email"
class="form-control"
placeholder="Your Email Address"
v-model="email"
>
<button type="submit">Submit</button>
</div>
<p v-if="errors.length">
<b>Please enter the following input value</b>
<ul>
<li v-for="error in errors">{{ error }}</li>
</ul>
</p>
</form>
JavaScript:
var subscribe = new Vue({
el: '#footerform-details',
data: { errors: [], email: null },
methods: {
checkForm: function (e) {
if (this.email) { return true; }
this.errors = [];
if (!this.email) {
this.errors.push('Email required.');
}
e.preventDefault();
}
},
})
【问题讨论】:
标签: javascript html vue.js vuejs2