# MMSwitch 滑动开关
# Props
# IMMSwitchProps
属性 | 类型 | 默认值 | 必传 | 说明 |
---|---|---|---|---|
checked | boolean | 是 | 选中状态 | |
disabled | boolean | 否 | 是否禁用 | |
onChange | (checked: boolean) => void | 否 | 改变事件 |
# 代码示例
import Taro from "@tarojs/taro";
import { FC, memo, useState } from "react";
import { View } from "@tarojs/components";
import styles from "./index.module.less";
import MMNavigation from "@wmeimob/taro-design/src/components/navigation";
import MMSwitch from "../../components/switch";
interface ISwitchProps {}
const Component: FC<ISwitchProps> = () => {
const [check, setCheck] = useState(true);
const [check2, setCheck2] = useState(true);
return (
<View className={styles.switchStyle}>
<MMNavigation title="switch" />
<MMSwitch checked={check} onChange={setCheck} />
<MMSwitch disabled checked={check2} onChange={setCheck2} />
</View>
);
};
const Switch = memo(Component);
export default Switch;