mobile.jsx 969 B

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