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图标
javascript 复制代码
<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>
javascript 复制代码
  methods: {
    changeType() {
      this.passwordType = this.passwordType == 'password' ? 'text' : 'password'
    },
    }
javascript 复制代码
.displayPass {
  ::v-deep .el-input__inner{
    -webkit-text-security: disc !important;
  }

实现效果

相关推荐
PineappleCoder1 天前
还在重复下载资源?HTTP 缓存让二次访问 “零请求”,用户体验翻倍
前端·性能优化
拉不动的猪1 天前
webpack编译中为什么不建议load替换ast中节点删除consolg.log
前端·javascript·webpack
李姆斯1 天前
Agent时代下,ToB前端的UI和交互会往哪走?
前端·agent·交互设计
源码获取_wx:Fegn08951 天前
基于springboot + vue健身房管理系统
java·开发语言·前端·vue.js·spring boot·后端·spring
闲谈共视1 天前
基于去中心化社交与AI智能服务的Web钱包商业开发的可行性
前端·人工智能·去中心化·区块链
CreasyChan1 天前
C# 反射详解
开发语言·前端·windows·unity·c#·游戏开发
JIngJaneIL1 天前
基于Java+ vue智慧医药系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
阿蒙Amon1 天前
JavaScript学习笔记:6.表达式和运算符
javascript·笔记·学习
hashiqimiya1 天前
两个步骤,打包war,tomcat使用war包
java·服务器·前端
小a杰.1 天前
Flutter 设计系统构建指南
开发语言·javascript·ecmascript