text-input.vue 727 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div class="input">
  3. <label>
  4. <span class="label"><slot></slot></span>
  5. <input type="text"
  6. :placeholder="placeholder"
  7. :class="{error: error}"
  8. v-bind:value="value"
  9. v-on:input="input">
  10. </label>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: "text-input",
  16. props: ['value', 'placeholder', 'error'],
  17. methods: {
  18. input: function(event) {
  19. this.$emit('clearError', null);
  20. this.$emit('input', event.target.value)
  21. }
  22. }
  23. }
  24. </script>
  25. <style scoped>
  26. .label {
  27. font-size: 80%;
  28. }
  29. input {
  30. width: 100%;
  31. margin-top: 0.2rem;
  32. }
  33. input.error {
  34. background-color: rgba(255, 0, 0, 0.3);
  35. border-color: var(--error);
  36. }
  37. </style>