The World of Remnant

大坑:如何阻止浏览器保存和填充密码

  <el-input
  :key="key"
  :type="type"
  size="large"
  ref="input"
  v-model="password"
  @keydown.native.enter="check"
  @keydown.native.delete="beforeDelete"
  @input="input"
  autocomplete="off"
  auto-complete="off"
  placeholder="密码"
  :disabled="disabled"
  ></el-input>
  beforeDelete(e) {
    const { value, selectionStart } = e.target
    if (!value.length) return
    if (value.length < 2 || selectionStart == 0) {
    this.type = 'text'
    this.key = Math.random()
    this.password = ''
    this.$nextTick(() => {
      this.$refs.input.focus()
    })
    }
  },
  input(v) {
    if (v.length) {
    this.type = 'password'
    }
  },

如果页面可能被多次打开,提交成功后再走一遍this.type = 'text'...