chrome浏览器去除密码框提示

65 阅读1分钟

chrome浏览器去除密码框提示

import Vue from "vue";

// 去除密码框填充和提示
Vue.directive("passward-disable-tips", {
  bind: function (el, binding) {
    const pwdTag = el.querySelector("input[type=password]");

    if (pwdTag) {
      pwdTag.setAttribute("readonly", "true");

      pwdTag.addEventListener("focus", function () {
        setTimeout(function () {
          pwdTag.removeAttribute("readonly");
        });
      });
      pwdTag.addEventListener("click", function () {
        setTimeout(function () {
          pwdTag.removeAttribute("readonly");
        });
      });
      pwdTag.addEventListener("blur", function () {
        pwdTag.setAttribute("readonly", "true");
      });
    }
  }
});