elementui 里使用input 密码框,输入时禁止弹出浏览器历史密码提示框

在elementui中使用el-input的type=password,实现密码输入框的展示隐藏时候,禁用浏览器历史

在这里插入图片描述
官方api上,使用autocomplete属性不生效
在这里插入图片描述
解决方案,使用css的 -webkit-text-security: disc; 属性

  1. el-input的type属性设置为text
  2. 使用suffix-icon,设置展示和隐藏时不同的图标
  3. 加上样式名,明文时展示a图标,密文时展示b图标
<el-input
              v-model.trim="basicForm.engineToken"
              type="password"
              :maxlength="250"
              placeholder="请输入引擎token"
              :class="passwordType == 'text' ? '' :'displayPass'"
              @input="changeValue"
            >
              <a slot="suffix">
                <i
                  :class="[
                    'iconfont',
                    passwordType === 'password'
                      ? 'iconfont el-icon-edit-invisible'
                      : 'iconfont el-icon-edit-visible',
                  ]"
                  @click="changeType"
                />
              </a>
            </el-input>
  methods: {
   
    changeType() {
   
      this.passwordType = this.passwordType == 'password' ? 'text' : 'password'
    },
    }
.displayPass {
   
  ::v-deep .el-input__inner{
   
    -webkit-text-security: disc !important;
  }

实现效果
在这里插入图片描述

最近更新

  1. TCP协议是安全的吗?

    2023-12-26 21:56:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-26 21:56:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-26 21:56:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-26 21:56:02       20 阅读

热门阅读

  1. 数据结构——常见的定义

    2023-12-26 21:56:02       31 阅读
  2. vue中样式动态绑定写法

    2023-12-26 21:56:02       30 阅读
  3. 红黑树的C语言简单实现与代码解析

    2023-12-26 21:56:02       42 阅读
  4. 阿里云“块存储”是系统盘和数据盘的意思

    2023-12-26 21:56:02       48 阅读