关于前端:完美解决-elementui-inputpassword-在浏览器会自动填充密码的问题

46次阅读

共计 917 个字符,预计需要花费 3 分钟才能阅读完成。

<el-form-item prop="password" :label="$t('bankcard_settings_98_4_35_zIbf')">
                    <el-input
                      :type="((readonly && ruleForm.password) || ruleForm.password)?'password':'text'":readonly="readonly"auto-complete="confirm-password"v-model="ruleForm.password":placeholder="$t('bankcard_settings_99_7_64_zMkJ')"@focus="changAttr($event,'focus')"@blur="changAttr($event,'blur')"@click.native="clickEvt"ref="password"
                    />
                  </el-form-item>

changAttr/clickEvt 办法

changAttr(e, type) {if (type === 'focus') {if (e) {e.stopPropagation();
          e.preventDefault();}
        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();}
          if (this.ruleForm.password === '' || this.readonly) {this.$refs.password.$refs.input.blur();
            setTimeout(() => {this.$refs.password.$refs.input.focus();
            }, 0);
          }
          return false;
        };
      }
    },

具体

正文完
 0