✨ feat(购物车): 使用context解决跨层级问题
This commit is contained in:
@@ -10,9 +10,9 @@ type params = {
|
||||
onSelect?: () => void //选择触发
|
||||
onClose?: () => void //取消触发
|
||||
status?: boolean //是否选中
|
||||
hidden?: boolean // 隐藏单选框
|
||||
hiddenCheckboxIcon?: boolean // 隐藏多选框
|
||||
disabled?: boolean //是否禁用
|
||||
triggerLabel?: boolean // 点击label是否触发选中
|
||||
triggerLabel?: boolean // 点击label是否触发选中
|
||||
circle?: boolean
|
||||
round?: boolean
|
||||
size?: CheckboxSize
|
||||
@@ -35,7 +35,7 @@ export default forwardRef((props: params, ref) => {
|
||||
customStyles = {},
|
||||
customClassName = '',
|
||||
customTextClass = '',
|
||||
hidden = false,
|
||||
hiddenCheckboxIcon = false,
|
||||
} = props
|
||||
const [selected, SetSelected] = useState(false)
|
||||
const onSelectEven = () => {
|
||||
@@ -81,11 +81,14 @@ export default forwardRef((props: params, ref) => {
|
||||
}, [status])
|
||||
return (
|
||||
<View className={classnames(customClassName, styles.checkbox)} style={customStyles} onClick={onSelectEven}>
|
||||
<View className={classnames(styles.checkbox_main, getMainClassName())} hidden={hidden}>
|
||||
<View className={classnames(styles.checkbox_item, getClassName())}>
|
||||
{selected && <IconFont name='icon-a-jizhumima' size={22} color='#fff'></IconFont>}
|
||||
{!hiddenCheckboxIcon && (
|
||||
<View className={classnames(styles.checkbox_main, getMainClassName())}>
|
||||
<View className={classnames(styles.checkbox_item, getClassName())}>
|
||||
{selected && <IconFont name='icon-a-jizhumima' size={22} color='#fff'></IconFont>}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{children && (
|
||||
<View className={classnames(styles['checkbox--text'], customTextClass)} onClick={handleClickChildren}>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user