GroupNumber.tsx 765 B

12345678910111213141516171819202122232425262728293031
  1. import { InputNumber } from "ant-design-vue";
  2. import { defineComponent } from "vue";
  3. import { any } from "vue-types";
  4. export const GroupNumber = defineComponent({
  5. props: {
  6. value: any<number[]>().def([]),
  7. labels: any<string[]>().def([]),
  8. },
  9. emits: ["change"],
  10. setup(props, { emit }) {
  11. function changeVal(index: number, v: any) {
  12. const { value } = props;
  13. value[index] = parseInt(v) || 0;
  14. emit("change", value);
  15. }
  16. return () => (
  17. <div class="flex space-x-4px">
  18. {props.labels.map((label, i) => (
  19. <InputNumber
  20. value={props.value[i]}
  21. key={i}
  22. addon-before={label}
  23. onChange={changeVal.bind(null, i)}
  24. />
  25. ))}
  26. </div>
  27. );
  28. },
  29. });