[improvement] Tabbar: jsx (#2663)

This commit is contained in:
neverland
2019-02-01 17:10:31 +08:00
committed by GitHub
parent 5b3992d4c2
commit b8ec2ffc5d
6 changed files with 85 additions and 102 deletions

View File

@@ -1,6 +1,7 @@
/**
* Common part of Checkbox & Radio
*/
import { useSlots } from '../utils';
import Icon from '../icon';
import findParent from './find-parent';
@@ -41,18 +42,18 @@ export default (parent, bem) => ({
},
render(h) {
const CheckIcon = this.$scopedSlots.icon ? (
this.$scopedSlots.icon({ checked: this.checked })
) : (
const { checked } = this;
const slots = useSlots(this);
const CheckIcon = slots('icon', { checked }) || (
<Icon name="success" style={this.iconStyle} />
);
const Label = this.$slots.default && (
const Label = slots('default') && (
<span
class={bem('label', [this.labelPosition, { disabled: this.isDisabled }])}
onClick={this.onClickLabel}
>
{this.$slots.default}
{slots('default')}
</span>
);
@@ -64,7 +65,7 @@ export default (parent, bem) => ({
}}
>
<div
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked: this.checked }])}
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked }])}
onClick={this.onClickIcon}
>
{CheckIcon}