index.js 914 B

1234567891011121314151617181920212223
  1. import { ElSwitch } from 'element-plus'
  2. import { useFormInput } from '@cip/components/hooks/form-input'
  3. import { formInputProps } from '../../form-input-props'
  4. import './index.less'
  5. export default {
  6. props: formInputProps,
  7. emits: ['update:modelValue'],
  8. setup (props, context) {
  9. const { proxyValue, securityConfig } = useFormInput(props, context)
  10. // el-switch组件监听checked值未做nextTick报错,对错误进行处理
  11. // onErrorCaptured(() => false)
  12. return () => <div class={'cip-switch__wrapper'}>
  13. <ElSwitch
  14. v-model={proxyValue.value}
  15. disabled={props.disabled}
  16. activeText={securityConfig.value.activeText ?? ''}
  17. inactiveText={securityConfig.value.inactiveText ?? ''}
  18. activeValue={securityConfig.value.activeValue ?? true}
  19. inactiveValue={securityConfig.value.inactiveValue ?? false}
  20. />
  21. </div>
  22. }
  23. }