NewSwitch.tsx 726 B

12345678910111213141516171819202122232425262728
  1. import { View, Switch } from "@tarojs/components";
  2. import './NewSwitch.scss'
  3. export default function NewSwitch(props: {
  4. disable: boolean,
  5. checked: boolean,
  6. color: string,
  7. onChange: any,
  8. onClick?: any
  9. }) {
  10. return <View className="switch_container">
  11. <Switch checked={props.checked}
  12. color={props.color}
  13. onChange={props.onChange}
  14. />
  15. {
  16. props.disable && <View className="switch_top" onClick={(e) => {
  17. if (process.env.TARO_ENV == 'weapp') {
  18. e.stopPropagation()
  19. }
  20. if (props.onClick) {
  21. props.onClick()
  22. }
  23. }} />
  24. }
  25. </View>
  26. }