Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b66c64f

Browse filesBrowse files
Jackyzmhazel54
authored andcommitted
checkbox value 允许传入0
1 parent 0da0d41 commit b66c64f
Copy full SHA for b66c64f

File tree

Expand file treeCollapse file tree

1 file changed

+21
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-11
lines changed
Open diff view settings
Collapse file

‎src/checkbox/CheckBoxGroup.jsx‎

Copy file name to clipboardExpand all lines: src/checkbox/CheckBoxGroup.jsx
+21-11Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* @flow */
22

3-
import React from 'react';
4-
import { Component, PropTypes } from '../../libs'
3+
import React from "react";
4+
import { Component, PropTypes } from "../../libs";
55

66
type State = {
7-
options: Array<string>,
8-
}
7+
options: Array<string>
8+
};
99

1010
export default class CheckboxGroup extends Component {
1111
state: State;
@@ -60,25 +60,35 @@ export default class CheckboxGroup extends Component {
6060

6161
const { elementType } = child.type;
6262
// 过滤非Checkbox和CheckboxButton的子组件
63-
if (elementType !== 'Checkbox' && elementType !== 'CheckboxButton') {
63+
if (elementType !== "Checkbox" && elementType !== "CheckboxButton") {
6464
return null;
6565
}
6666

6767
return React.cloneElement(
6868
child,
6969
Object.assign({}, child.props, {
7070
key: index,
71-
checked: child.props.checked || options.indexOf(child.props.value) >= 0 || options.indexOf(child.props.label) >= 0 ,
72-
onChange: this.onChange.bind(this, child.props.value || child.props.label),
73-
}),
71+
checked:
72+
child.props.checked ||
73+
options.indexOf(child.props.value) >= 0 ||
74+
options.indexOf(child.props.label) >= 0,
75+
onChange: this.onChange.bind(
76+
this,
77+
child.props.value
78+
? child.props.value
79+
: child.props.value === 0
80+
? 0
81+
: child.props.label
82+
)
83+
})
7484
);
7585
});
7686

7787
return (
78-
<div style={this.style()} className={this.className('el-checkbox-group')}>
88+
<div style={this.style()} className={this.className("el-checkbox-group")}>
7989
{children}
8090
</div>
81-
)
91+
);
8292
}
8393
}
8494

@@ -93,5 +103,5 @@ CheckboxGroup.propTypes = {
93103
fill: PropTypes.string,
94104
textColor: PropTypes.string,
95105
value: PropTypes.any,
96-
onChange: PropTypes.func,
106+
onChange: PropTypes.func
97107
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.