fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<template>
  <a-space>
    <template v-for="(item, i) in value" :key="i">
      <mars-input v-model:value="values[i]" @change="(v) => itemChange(v, i)" :suffix="props.units[i]" />
    </template>
  </a-space>
</template>
<script lang="ts" setup>
import { watchEffect, ref } from "vue"
const props = defineProps<{
  value: string[]
  units: string[]
}>()
 
const values = ref([])
 
watchEffect(() => {
  values.value = props.value
})
 
const emits = defineEmits(["update:value", "change"])
 
function itemChange(v, i) {
  emits("update:value", values)
  emits("change", values)
}
</script>
<script lang="ts">
export default {
  name: "mars-input-group"
}
</script>
<style lang="less" scoped></style>