未隐藏状态图:
隐藏状态图:
部分代码如下:
html
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
:type='!isShow?"password":"text"'
auto-complete="off"
placeholder="密码"
@keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
<svg-icon v-if="isShow" slot="suffix" icon-class="icon(249)" class="el-input__icon input-icon-show" @click="passwordIsShow" />
<svg-icon v-if="!isShow" slot="suffix" icon-class="icon(250)" class="el-input__icon input-icon-show" @click="passwordIsShow" />
</el-input>
</el-form-item>
javascript:
//控制密码隐藏
passwordIsShow(){
this.isShow =!this.isShow
},
注意:type类型参考原生input类型:password(密码)、color(颜色)等属性、text(文字)
原生input解释:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types\