Input.vue 958 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template lang="html">
  2. <div class="base-input__wrapper">
  3. <label class="base-input__label" v-if="label">
  4. {{ label }}
  5. </label>
  6. <input
  7. :value="value"
  8. @input="updateValue"
  9. v-on="listeners"
  10. :v-bind="$attrs"
  11. :class="'base-input ' + className"
  12. :type="inputType"
  13. @keyup.enter="keyupEnter"
  14. />
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. inheritAttrs: false,
  20. props: {
  21. inputType: {
  22. type: String,
  23. default: "text"
  24. },
  25. label: {
  26. type: String,
  27. defaul: "",
  28. },
  29. value: [String, Number],
  30. className: {
  31. type: String
  32. }
  33. },
  34. methods: {
  35. updateValue(event) {
  36. this.$emit("input", event.target.value);
  37. },
  38. keyupEnter() {
  39. this.$emit("keyupEnter");
  40. }
  41. },
  42. computed: {
  43. listeners() {
  44. return {
  45. ...this.$listeners,
  46. input: this.updateValue,
  47. };
  48. },
  49. },
  50. };
  51. </script>
  52. <style lang="less">
  53. </style>