-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(checkbox group): checkbox group support disable specified item. #1218
feat(checkbox group): checkbox group support disable specified item. #1218
Conversation
const optionsWithDisabled = [ | ||
{ label: '苹果', value: 'Apple' }, | ||
{ label: '梨', value: 'Pear' }, | ||
{ label: '橙子', value: 'Orange', disabled: false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个例子同时使用了子项和整个 Group 的 disabled 特性。整个 Group disabled, 某个 enabled
81d8299
to
a915fca
Compare
{option.label} | ||
</Checkbox> | ||
options.map(option => { | ||
const disabled = Object.hasOwnProperty.call(option, 'disabled') ? option.disabled : this.props.disabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此处可以简单的用 'disabled' in option
来判断。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能,disabled 是特殊属性,会抛出异常。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不会吧,option 是普通对象。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
奇怪,刚试了下,又没问题了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦,想起来了,昨天是基于 master 改的,option 是字符串的时候会抛出异常。
a915fca
to
e0172ca
Compare
好了,再看看。 |
feat(checkbox group): checkbox group support disable specified item.
First of all, thanks for your contribution! :-)
Please makes sure these boxes are checked before submitting your PR, thank you!
[x] Run
npm run lint
and fix those errors before submitting in order to keep consistent code style.[x] Rebase before creating a PR to keep commit history clear.
[x] Add some descriptions and refer relative issues for you PR.
支持在 Checkbox Group 的子项中指定 disabled 属性。