mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 03:44:48 +00:00
[improvement] Functional components be just functions (#2735)
This commit is contained in:
@@ -2,31 +2,32 @@ import { use } from '../utils';
|
||||
import { inherit } from '../utils/functional';
|
||||
import Cell from '../cell';
|
||||
import Switch from '../switch';
|
||||
import SwitchMixin from '../mixins/switch';
|
||||
import { switchProps } from '../switch/shared';
|
||||
|
||||
const [sfc, bem] = use('switch-cell');
|
||||
|
||||
export default sfc({
|
||||
functional: true,
|
||||
function SwitchCell(h, props, slots, ctx) {
|
||||
return (
|
||||
<Cell
|
||||
center
|
||||
title={props.title}
|
||||
border={props.border}
|
||||
class={bem()}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
<Switch {...{ props, on: ctx.listeners }} />
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
|
||||
mixins: [SwitchMixin],
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
border: Boolean,
|
||||
size: {
|
||||
type: String,
|
||||
default: '24px'
|
||||
}
|
||||
},
|
||||
|
||||
render(h, context) {
|
||||
const { props } = context;
|
||||
|
||||
return (
|
||||
<Cell center title={props.title} border={props.border} class={bem()} {...inherit(context)}>
|
||||
<Switch {...{ props, on: context.listeners }} />
|
||||
</Cell>
|
||||
);
|
||||
SwitchCell.props = {
|
||||
...switchProps,
|
||||
title: String,
|
||||
border: Boolean,
|
||||
size: {
|
||||
type: String,
|
||||
default: '24px'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default sfc(SwitchCell);
|
||||
|
||||
Reference in New Issue
Block a user