index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <el-input v-model="proxyValue"
  3. :placeholder="placeholder"
  4. :disabled="disabled"
  5. :style="{width}"
  6. :maxlength="limit"
  7. :show-word-limit="showWordLimit && !!limit"
  8. :clearable="clearable"
  9. ref="inputRef"></el-input>
  10. </template>
  11. <script>
  12. import { ElInput } from 'element-plus'
  13. import { useFormInput } from '@cip/components/hooks/form-input'
  14. import { formInputProps } from '../../form-input-props'
  15. import { useInputConfig } from './use-input-config'
  16. export default {
  17. name: 'BasicInput',
  18. components: { ElInput },
  19. props: formInputProps,
  20. emits: ['update:modelValue'],
  21. setup (props, context) {
  22. const formInput = useFormInput(props, context)
  23. const { width, proxyValue, clearable, inputRef } = formInput
  24. const { placeholder, limit, showWordLimit } = useInputConfig(formInput)
  25. context.expose({
  26. focus: () => { inputRef.value.focus() }
  27. })
  28. return {
  29. inputRef,
  30. proxyValue,
  31. placeholder,
  32. limit,
  33. showWordLimit,
  34. width,
  35. clearable
  36. }
  37. }
  38. }
  39. </script>