import React, { useState } from 'react';
import { Switch, View, Text } from '@ray-js/ray';
export default function () {
const [checked, setChecked] = useState(false);
return (
<View style={{ padding: '20px' }}>
<View style={{ marginBottom: '16px' }}>
<Text>受控开关:</Text>
<Switch
checked={checked}
onChange={(e) => {
console.log('Switch 改变:', e.detail.value);
setChecked(e.detail.value);
}}
style={{ marginTop: '8px' }}
/>
<Text style={{ marginTop: '8px' }}>当前状态: {checked ? '开' : '关'}</Text>
</View>
<View style={{ marginBottom: '16px' }}>
<Text>自定义颜色:</Text>
<Switch color="#ff0000" checked style={{ marginTop: '8px' }} />
</View>
<View style={{ marginBottom: '16px' }}>
<Text>禁用状态:</Text>
<Switch disabled style={{ marginTop: '8px' }} />
</View>
<View style={{ marginBottom: '16px' }}>
<Text>Checkbox 类型:</Text>
<Switch type="checkbox" checked style={{ marginTop: '8px' }} />
</View>
</View>
);
}