• 完美禁用elinput type为password自动填充密码功能


    1.autoComplete='new-password'
    2.autoComplete='off'
    上述两种情况都无效

    html部分代码
    <el-form-item
                           :prop="'paramList.' + scope.$index + '.paramValue'"
                            :rules="paramsRules.paramValue"
                          >
                            <template v-if="scope.row.paramCode ==='password'">
                              <el-input
                                type="password"
                                :autoComplete="scope.row.paramCode === 'password'? 'new-password' : 'off'"
                                :value='scope.row.paramValue'
                                @input='pwdInput($event,scope.row)'
                                placeholder='请输入参数值'
                                :readonly="readonly" <!--默认是true--->
                                auto-complete="confirm-password"
                                @focus="changAttr($event,'focus')"
                                @blur="changAttr($event,'blur')"
                                @click.native="clickEvt"
                                ref="password"
                              >
                              </el-input>
                            </template>
                            <template v-else>
                              <el-input
                                v-model='scope.row.paramValue'
                                placeholder='请输入参数值'
                              >
                              </el-input>
                            </template>
                          </el-form-item>
    

      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;
            };
          }
        },
    }
    

      

  • 相关阅读:
    Redis "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk"问题的解决
    素描
    python 标准库
    Python内置函数filter, map, reduce
    Python的lambda表达式
    python中super关键字的用法
    python一个注意的地方
    python中self,cls
    python中的实例方法、静态方法、类方法、类变量和实例变量
    python模块及包的导入
  • 原文地址:https://www.cnblogs.com/tw6668/p/16257670.html
Copyright © 2020-2023  润新知