mobile.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { computed, inject } from 'vue'
  2. import { Field as VanField } from 'vant'
  3. import { useFormInput } from '../../../hooks/form-input'
  4. import { formInputProps } from '../../form-input-props'
  5. export default {
  6. props: formInputProps,
  7. setup (props, context) {
  8. const cipConfig = inject('cip-config', {})
  9. const { emitModelValue, clearable, placeholder } = useFormInput(props, context)
  10. const limit = computed(() => {
  11. return props.config?.limit ?? cipConfig?.limit?.input ?? undefined
  12. })
  13. const autosize = computed(() => {
  14. if (props.config?.autosize) {
  15. const { minRows, maxRows } = props.config?.autosize
  16. return { minHeight: minRows * 30, maxHeight: maxRows * 30 }
  17. }
  18. return { minHeight: 60, maxHeight: 100 }
  19. })
  20. /* vant中clear使用的是touchStart事件,浏览器中click无效 */
  21. return () => <VanField modelValue={props.modelValue}
  22. onUpdate:modelValue={emitModelValue}
  23. type="textarea"
  24. clearable={clearable.value}
  25. placeholder={placeholder.value}
  26. autosize={autosize.value}
  27. maxlength={limit.value}
  28. show-word-limit={!!limit.value}
  29. />
  30. }
  31. }