password.html 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. {{define "component/passwordInput"}}
  2. <template>
  3. <a-input :value="value" :type="showPassword ? 'text' : 'password'"
  4. :placeholder="placeholder"
  5. :autocomplete="autocomplete"
  6. :name="name"
  7. @input="$emit('input', $event.target.value)">
  8. <template v-if="icon" #prefix>
  9. <a-icon :type="icon" style="font-size: 16px;" />
  10. </template>
  11. <template #addonAfter>
  12. <a-icon :type="showPassword ? 'eye-invisible' : 'eye'"
  13. @click="toggleShowPassword"
  14. style="font-size: 16px;" />
  15. </template>
  16. </a-input>
  17. </template>
  18. {{end}}
  19. {{define "component/password"}}
  20. <script>
  21. Vue.component('password-input', {
  22. props: ["title", "value", "placeholder", "icon", "autocomplete", "name"],
  23. template: `{{template "component/passwordInput"}}`,
  24. data() {
  25. return {
  26. showPassword: false,
  27. };
  28. },
  29. methods: {
  30. toggleShowPassword() {
  31. this.showPassword = !this.showPassword;
  32. },
  33. },
  34. });
  35. </script>
  36. {{end}}