password.html 977 B

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