【发布时间】:2021-02-28 14:36:05
【问题描述】:
export default {
name: "HelloWworld",
data: function () {
return {
isHidden: false,
isWelcome: false,
isFadeout: false,
}
}
<div v-if="!isHidden">
//some code for screen1
<button v-on:click="isHidden = true"> HELLO</button>
</div>
<div v-else-if="isHidden && !isFadeout">
//some code for screen 2
<button v-on:click="isFadeout = true"> Hi</button>
</div>
<div v-else-if="isFadeout && isHidden && !isWelcome">
<input
:type="passwordFieldType"
v-model="user.password"
id="password"
name="password"
class="input-section-three"
:class="{ 'is-invalid': submitted && $v.user.password.$error }"
placeholder="Enter new password"
:maxlength="maxpassword"
v-on:keypress="isPassword($event)"
/>
<div
v-if="submitted && $v.user.password.$error"
class="invalid-feedback-two"
>
<span v-if="!$v.user.password.required">Password is required</span>
<span v-if="!$v.user.password.minLength"
>Minimum 8 character with
alphanumeric along with 1 capital letter, 1 small letter
and 1 special character at least</span
>
</div>
<input
:type="passwordFieldTypetwo"
v-model="user.confirmPassword"
id="confirmPassword"
name="confirmPassword"
class="input-section-three"
:class="{
'is-invalid': submitted && $v.user.confirmPassword.$error
}"
placeholder="Confirm password"
:maxlength="maxconfirmpassword"
v-on:keypress="isconfirmPassword($event)"
:disabled="user.password.length < 8"
/>
<div
v-if="submitted && $v.user.confirmPassword.$error"
class="invalid-feedback-two"
>
<span v-if="!$v.user.confirmPassword.required"
>Confirm Password is required</span
>
<span v-else-if="!$v.user.confirmPassword.sameAsPassword"
>Password must match</span
>
</div>
<button v-on:click="isWelcome = user.confirmPassword.length >= 8"
> SUBMIT </button>
</div>
<div v-else-if="isWelcome">
//some code for screen 4
<button>Fine</button>
</div>
问题是,最初如果我单击屏幕 3 中的提交按钮,验证工作正常,但如果我输入的密码不匹配,但如果超过 8 个字符,则在密码确认字段中。它正在重定向到第四个屏幕。但我想做的是,如果密码与确认密码字段匹配,则只需要重定向到第 4 个屏幕。
【问题讨论】: