Skip to content

Commit eee125d

Browse files
committed
修复 FaPinInput 组件输入bug
1 parent 8f2745a commit eee125d

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

src/ui/components/FaPinInput/index.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { PinInput, PinInputGroup, PinInputInput } from './pin-input'
2+
import { PinInput, PinInputGroup, PinInputSlot } from './pin-input'
33
44
defineOptions({
55
name: 'FaPinInput',
@@ -26,10 +26,6 @@ watch(modelValue, (val) => {
2626
value.value = val?.split('') ?? []
2727
})
2828
29-
watch(value, (val) => {
30-
modelValue.value = val.join('')
31-
})
32-
3329
function handleComplete(e: string[]) {
3430
modelValue.value = e.join('')
3531
emit('complete')
@@ -39,9 +35,9 @@ const id = useId()
3935
</script>
4036

4137
<template>
42-
<PinInput :id :model-value="value" placeholder="" otp @complete="handleComplete" @update:model-value="arrStr => value = arrStr.filter(Boolean)">
38+
<PinInput :id v-model="value" placeholder="" otp @complete="handleComplete">
4339
<PinInputGroup>
44-
<PinInputInput v-for="(item, index) in length" :key="item" :index="index" />
40+
<PinInputSlot v-for="(item, index) in length" :key="item" :index="index" />
4541
</PinInputGroup>
4642
</PinInput>
4743
</template>

src/ui/components/FaPinInput/pin-input/PinInputGroup.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { cn } from '@/utils'
77
88
const props = defineProps<PrimitiveProps & { class?: HTMLAttributes['class'] }>()
99
const delegatedProps = reactiveOmit(props, 'class')
10+
1011
const forwardedProps = useForwardProps(delegatedProps)
1112
</script>
1213

1314
<template>
1415
<Primitive v-bind="forwardedProps" :class="cn('flex items-center', props.class)">
1516
<slot />
16-
</primitive>
17+
</Primitive>
1718
</template>

src/ui/components/FaPinInput/pin-input/PinInputSeparator.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ const forwardedProps = useForwardProps(props)
1212
<slot>
1313
<Dot />
1414
</slot>
15-
</primitive>
15+
</Primitive>
1616
</template>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { default as PinInput } from './PinInput.vue'
22
export { default as PinInputGroup } from './PinInputGroup.vue'
3-
export { default as PinInputInput } from './PinInputInput.vue'
43
export { default as PinInputSeparator } from './PinInputSeparator.vue'
4+
export { default as PinInputSlot } from './PinInputSlot.vue'

0 commit comments

Comments
 (0)