完美禁用el-input type为password自动填充密码功能
1.autoComplete='new-password'
2.autoComplete='off'
上述两种情况都无效
html部分代码
auto-complete="confirm-password" @focus="changAttr($event,'focus')" @blur="changAttr($event,'blur')" @click.native="clickEvt" ref="password" >
js代码
methods: {
pwdInput(e,row) {
row.paramValue = e
if(!e) {
this.readonly = true
}
},
changAttr(e, type) {
if (type === 'focus') {
if (e) {
e.stopPropagation();
e.preventDefault();
console.log(e.target.value)
}
setTimeout(() => {
this.readonly = false;
}, 100);
} else {
if (e) {
e.stopPropagation();
}
this.readonly = true;
}
},
clickEvt() {
if (this.$refs.password) {
this.$refs.password.$refs.input.onmousedown = (evt) => {
if (evt) {
evt.preventDefault();
evt.stopPropagation();
}
console.log(this.$refs.password.$refs.input.value)
if (this.$refs.password.$refs.input.value ==='' || this.readonly) {
this.$refs.password.$refs.input.blur();
setTimeout(() => {
this.$refs.password.$refs.input.focus();
}, 0);
}
return false;
};
}
},
}