mobile.jsx 1013 B

12345678910111213141516171819202122232425262728
  1. import { watch } from 'vue'
  2. import { Field as VanField } from 'vant'
  3. import { useFormInput, useElementFormEvent } from '../../../hooks/form-input'
  4. import {formInputProps, fromInputEmits} from '../../form-input-props'
  5. import { useInputConfig } from './use-input-config'
  6. export default {
  7. props: formInputProps,
  8. emits: [...fromInputEmits],
  9. setup (props, context) {
  10. const formInput = useFormInput(props, context)
  11. const { handleBlur, handleChange } = useElementFormEvent()
  12. const { width, proxyValue, clearable } = formInput
  13. const { placeholder, limit, showWordLimit } = useInputConfig(formInput)
  14. watch(proxyValue, (val) => {
  15. handleChange(val)
  16. })
  17. return () => <VanField
  18. v-model={proxyValue.value}
  19. placeholder={placeholder.value}
  20. disabled={props.disabled}
  21. style={{ width: width.value }}
  22. maxLength={limit.value}
  23. showWordLimit={showWordLimit.value}
  24. clearable={clearable.value}
  25. onBlur={() => handleBlur(proxyValue.value)}
  26. />
  27. }
  28. }