mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
44 lines
947 B
JavaScript
44 lines
947 B
JavaScript
import { use } from '../utils';
|
|
import Icon from '../icon';
|
|
import { emit, inherit, unifySlots } from '../utils/functional';
|
|
import { functionalRoute, routeProps } from '../mixins/router';
|
|
|
|
const [sfc, bem] = use('goods-action-mini-btn');
|
|
|
|
export default sfc({
|
|
functional: true,
|
|
|
|
props: {
|
|
...routeProps,
|
|
text: String,
|
|
icon: String,
|
|
info: [String, Number],
|
|
iconClass: String
|
|
},
|
|
|
|
render(h, context) {
|
|
const { props } = context;
|
|
const slots = unifySlots(context);
|
|
|
|
const onClick = event => {
|
|
emit(context, 'click', event);
|
|
functionalRoute(context);
|
|
};
|
|
|
|
return (
|
|
<div
|
|
class={[bem(), 'van-hairline']}
|
|
onClick={onClick}
|
|
{...inherit(context)}
|
|
>
|
|
<Icon
|
|
class={[bem('icon'), props.iconClass]}
|
|
info={props.info}
|
|
name={props.icon}
|
|
/>
|
|
{slots.default ? slots.default() : props.text}
|
|
</div>
|
|
);
|
|
}
|
|
});
|