index.jsx 969 B

123456789101112131415161718192021222324
  1. import { ElSwitch } from 'element-plus'
  2. import { useFormInput } from '@cip/components/hooks/form-input'
  3. import { formInputProps, fromInputEmits } from '../../form-input-props'
  4. import './index.less'
  5. export default {
  6. props: formInputProps,
  7. emits: [...fromInputEmits, 'change'],
  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. onChange={val => context.emit('change', val)}
  21. />
  22. </div>
  23. }
  24. }