input输入框type=‘password’时,获取光标时总显示记住密码列表

input输入框type=‘password’时,获取光标时总显示记住密码列表

背景:
上周在开发修改密码功能的时候,发现在chrome浏览器input输入框type=‘password’时,获取光标总是显示记住密码列表,度娘上找的解决方案都试了,并没有什么卵用。

最后用了简单粗暴的解决方案,仅供参考,各路大神如有更好的解决方案,欢迎留言探讨。

解决思路:
input输入框type='text'的时候获取光标不会显示密码列表,写两个input,默认显示type='text'的输入框,如果input的value大于0,隐藏type='text'输入框,显示type='password'的输入框,显示type='text'输入框,隐藏type='password'。

代码:
html部分:

    
        
        
      

js部分:

    oldPasswordChangeHandle() {
      let oldLoginPwd = this.formLogin.oldLoginPwd
      if (oldLoginPwd.length > 0) return this.showOldPassWord = true
      this.showOldPassWord = false
    }

你可能感兴趣的:(前端,javascript,html)