zhangzengfei
2022-08-19 3e4904fda5c78cfd8b40fa925fd2970b01850224
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
  <el-input
    :placeholder="placeholder"
    class="PwInput"
    :type="flag ? 'text' : 'password'"
    v-model="inputVal"
    @input="input"
    autocomplete="off"
  >
    <i slot="prefix" class="iconfont" v-if="showPreIcon">&#xe608;</i>
 
    <i
      slot="suffix"
      class="iconfont showPass"
      autocomplete="auto"
      @click="flag = !flag"
    >
      {{ flag ? "&#xe60a;" : "&#xe609;" }}
    </i>
  </el-input>
</template>
 
<script>
export default {
  props: {
    value: {},
    showPreIcon: {},
    placeholder: {
      default: "请输入密码",
    },
  },
  data() {
    return {
      flag: false,
      inputVal: this.value,
    };
  },
  methods: {
    input() {
      this.$emit("input", this.inputVal);
    },
  },
  watch: {
    value(val) {
      this.inputVal = val;
    },
  },
};
</script>
 
<style lang="scss" >
.PwInput {
  .showPass {
    margin-top: 8px;
    font-size: 24px;
    cursor: pointer;
  }
}
</style>