1234567891011121314151617181920212223242526272829303132 |
- import { computed, inject } from 'vue'
- import { Field as VanField } from 'vant'
- import { useFormInput } from '../../../hooks/form-input'
- import { formInputProps } from '../../form-input-props'
- export default {
- props: formInputProps,
- setup (props, context) {
- const cipConfig = inject('cip-config', {})
- const { emitModelValue, clearable, placeholder } = useFormInput(props, context)
- const limit = computed(() => {
- return props.config?.limit ?? cipConfig?.limit?.input ?? undefined
- })
- const autosize = computed(() => {
- if (props.config?.autosize) {
- const { minRows, maxRows } = props.config?.autosize
- return { minHeight: minRows * 30, maxHeight: maxRows * 30 }
- }
- return { minHeight: 60, maxHeight: 100 }
- })
- /* vant中clear使用的是touchStart事件,浏览器中click无效 */
- return () => <VanField modelValue={props.modelValue}
- onUpdate:modelValue={emitModelValue}
- type="textarea"
- clearable={clearable.value}
- placeholder={placeholder.value}
- autosize={autosize.value}
- maxlength={limit.value}
- show-word-limit={!!limit.value}
- />
- }
- }
|