input输入框取消账号密码提示 #去除自动填充提示
vue项目 iview UI 或 element-ui 项目均有效
未关闭前:
代码实现:
<Input password placeholder="请输入密码"
:key="pwKey"
v-model.trim="formLock.password"
@keyup.enter.native="handleSubmit()"
:type="pwType"
@input="pwInput">
</Input>
js:
data () {
return {
pwType: 'text', // 密码input默认属性
pwKey: 0, // 密码key值
formLock: {
password: ''
}
}
}
methods: {
// 修改input输入框的type属性
pwInput (e) {
if (e) {
this.pwType = 'password'
} else {
this.pwKey++
this.pwType = 'text'
}
},
// 按钮:确认
handleSubmit () {
this.$nextTick(() => {
this.pwInput()
}, 100)
}
// 取消
handleReset () {
this.formLock.password = ''
this.$nextTick(() => {
this.pwInput()
})
},
效果: