EditDimension.vue 832 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <span style="padding-left: 10px">
  3. <span>{{ props.label }}: </span>
  4. <ElInput
  5. style="width: 50px"
  6. size="small"
  7. @input="handleChange"
  8. v-model="val"
  9. :disabled="props.disabled"
  10. />
  11. </span>
  12. </template>
  13. <script lang="ts" setup>
  14. import { ref, watch } from 'vue';
  15. import { ElInput } from 'element-plus';
  16. const props = defineProps<{ label: string; modelValue: number; disabled?: boolean }>();
  17. const val = ref();
  18. watch(
  19. () => props.modelValue,
  20. () => {
  21. val.value = Math.floor(props.modelValue);
  22. },
  23. { immediate: true },
  24. );
  25. const emits = defineEmits<{ (e: 'update:modelValue', val: number): unknown }>();
  26. const handleChange = (e) => {
  27. emits('update:modelValue', Number(e));
  28. };
  29. </script>
  30. <style scoped></style>