aPasswordInput.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{define "component/passwordInput"}}
  2. <template>
  3. <a-input :value="value" :type="showPassword ? 'text' : 'password'" :placeholder="placeholder"
  4. :autocomplete="autocomplete" :name="name" @input="$emit('input', $event.target.value)">
  5. <template v-if="icon" #prefix>
  6. <a-icon :type="icon" style="font-size: 16px;" />
  7. </template>
  8. <template #addonAfter>
  9. <a-icon :type="showPassword ? 'eye-invisible' : 'eye'" @click="toggleShowPassword" style="font-size: 16px;" />
  10. </template>
  11. </a-input>
  12. </template>
  13. {{end}}
  14. {{define "component/aPasswordInput"}}
  15. <script>
  16. Vue.component('a-password-input', {
  17. props: {
  18. 'title': {
  19. type: String,
  20. required: false,
  21. },
  22. 'value': {
  23. type: String,
  24. required: false,
  25. },
  26. 'placeholder': {
  27. type: String,
  28. required: false,
  29. },
  30. 'autocomplete': {
  31. type: String,
  32. required: false,
  33. },
  34. 'name': {
  35. type: String,
  36. required: false,
  37. },
  38. 'icon': {
  39. type: undefined,
  40. required: false
  41. }
  42. },
  43. template: `{{template "component/passwordInput"}}`,
  44. data() {
  45. return {
  46. showPassword: false,
  47. };
  48. },
  49. methods: {
  50. toggleShowPassword() {
  51. this.showPassword = !this.showPassword;
  52. },
  53. },
  54. });
  55. </script>
  56. {{end}}