InputWithUnits.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="field has-addons">
  3. <p class="control">
  4. <a class="button is-static input-with-units-title">
  5. {{ title }}
  6. </a>
  7. </p>
  8. <p class="control">
  9. <b-input v-model="valueLocal" type="number" step="any"
  10. class="input-with-units-value"></b-input>
  11. </p>
  12. <p class="control">
  13. <a class="button is-static input-with-units-units">
  14. {{ units }}
  15. </a>
  16. </p>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "InputWithUnits",
  22. watch: {
  23. valueLocal: {
  24. handler: function () {
  25. this.$emit('newdata',this.valueLocal);
  26. }
  27. },
  28. deep: true
  29. },
  30. data () {
  31. return {
  32. // TODO: Is it OK to modify valueLocal later in <b-input>?
  33. valueLocal: this.value
  34. }
  35. },
  36. props: ['title', 'units', 'value']
  37. }
  38. </script>
  39. <style scoped>
  40. .input-with-units-title {
  41. width:4rem;
  42. }
  43. .input-with-units-value {
  44. width:6rem;
  45. }
  46. .input-with-units-units {
  47. width:3rem;
  48. }
  49. </style>