[improvement] Functional components be just functions (#2735)
This commit is contained in:
@@ -1,43 +1,38 @@
|
||||
import { use } from '../utils';
|
||||
import Button from '../button';
|
||||
import { emit, inherit, unifySlots } from '../utils/functional';
|
||||
import { emit, inherit } from '../utils/functional';
|
||||
import { functionalRoute, routeProps } from '../mixins/router';
|
||||
|
||||
const [sfc, bem] = use('goods-action-big-btn');
|
||||
|
||||
export default sfc({
|
||||
functional: true,
|
||||
function GoodsActionBigBtn(h, props, slots, ctx) {
|
||||
const onClick = event => {
|
||||
emit(ctx, 'click', event);
|
||||
functionalRoute(ctx);
|
||||
};
|
||||
|
||||
props: {
|
||||
...routeProps,
|
||||
text: String,
|
||||
primary: Boolean,
|
||||
loading: Boolean,
|
||||
disabled: Boolean
|
||||
},
|
||||
return (
|
||||
<Button
|
||||
square
|
||||
class={bem()}
|
||||
size="large"
|
||||
loading={props.loading}
|
||||
disabled={props.disabled}
|
||||
type={props.primary ? 'danger' : 'warning'}
|
||||
onClick={onClick}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
{slots.default ? slots.default() : props.text}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
render(h, context) {
|
||||
const { props } = context;
|
||||
const slots = unifySlots(context);
|
||||
GoodsActionBigBtn.props = {
|
||||
...routeProps,
|
||||
text: String,
|
||||
primary: Boolean,
|
||||
loading: Boolean,
|
||||
disabled: Boolean
|
||||
};
|
||||
|
||||
const onClick = event => {
|
||||
emit(context, 'click', event);
|
||||
functionalRoute(context);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
square
|
||||
class={bem()}
|
||||
size="large"
|
||||
loading={props.loading}
|
||||
disabled={props.disabled}
|
||||
type={props.primary ? 'danger' : 'warning'}
|
||||
onClick={onClick}
|
||||
{...inherit(context)}
|
||||
>
|
||||
{slots.default ? slots.default() : props.text}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
});
|
||||
export default sfc(GoodsActionBigBtn);
|
||||
|
||||
Reference in New Issue
Block a user