<div class="form">
<div class="input">
<label for="username">用户名</label>
<input type="text" name="username" id="user" v-validate="{required:true,max:6,min:4}" :class="{highlight:green==1,error:errors.has(‘username‘)}" @click="green=1">
</div>
<div class="input" >
<label for="password">密码</label>
<input type="password" name="password" id="pass" :class="{highlight:green==2,error:errors.has(‘password‘)}" v-validate="{required:true,max:6,min:4}" @click="green=2">
</div>
<span class="errTips" v-show="errors.has(‘password‘)">
{{ errors.first(‘password‘)}}
</span>
<span class="errTips" v-show="errors.has(‘username‘)">
{{ errors.first(‘username‘)}}
</span>
需求3核心实现代码
<div class="test">
<div class="rember" @click="rememberSet" :class="{active:remember}">
<span class="iconfont" :class="{‘icon-kuang‘:!remember,‘icon-android-checkbox‘:remember}">记住密码</span>
</div>
<div class="autoLogin" @click="autoLogin" :class="{active:autologin}">
<span class="iconfont" :class="{‘icon-kuang‘:!autologin,‘icon-android-checkbox‘:autologin}">自动登录</span>
</div>
</div>
rememberSet(){
this.remember =!this.remember
this.remember ||(this.autologin =false)
},
autoLogin(){
this.autologin =!this.autologin
this.autologin && (this.remember=true)
},
下面这段代码的实现需求是,当我点击自动登陆的时候,也就是autologin为true时自动登录也勾选上,当不勾选记住密码时自动登录也不勾上,也就是当remember为false时自动登录也为false