Skip to content

Commit

Permalink
fix(ui/input): when the value is a number, the input type is not number
Browse files Browse the repository at this point in the history
affects: @varlet/ui
  • Loading branch information
haoziqaq committed Aug 12, 2021
1 parent a0505b9 commit 34d750a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/varlet-ui/src/input/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ export default defineComponent({
const el: Ref<HTMLInputElement | null> = ref(null)
const isFocus: Ref<boolean> = ref(false)
const isNumberValue: ComputedRef<boolean> = computed(() => isNumber(props.modelValue))
const type: ComputedRef<'number' | 'text' | 'password'> = computed(() => {
const { type } = props
if (type === 'password') {
return type
}
if (isNumberValue.value) {
return 'number'
}
return 'text'
})
const maxlengthText: ComputedRef<string> = computed(() => {
const { maxlength, modelValue } = props
Expand Down Expand Up @@ -244,6 +257,7 @@ export default defineComponent({
return {
el,
type,
id,
isFocus,
errorMessage,
Expand Down

0 comments on commit 34d750a

Please sign in to comment.