import React from 'react'; import { View, Input } from '@tarojs/components'; import className from 'classnames'; interface ISwitchProps { /** 状态 */ checked: boolean; /** 禁用 */ disabled?: boolean; /** 变更回调 */ onChange?: () => void; } /** * 开关组件 */ const Switch: React.FC = ({ checked = false, disabled = false, onChange = () => {}, }) => { const checkStyle = className( 'switch', checked && 'switch-checked', disabled && !checked && 'disabled', disabled && checked && 'checked-disabled', ); return ( !disabled && onChange()} className='wm-switch-box'> ); }; export default Switch;