import { defineComponent } from 'vue'; import { extend, createNamespace, unknownProp } from '../utils'; import { ACTION_BAR_KEY } from '../action-bar/ActionBar'; // Composables import { useParent } from '@vant/use'; import { useRoute, routeProps } from '../composables/use-route'; // Components import { Icon } from '../icon'; import { Badge } from '../badge'; const [name, bem] = createNamespace('action-bar-icon'); export default defineComponent({ name, props: extend({}, routeProps, { dot: Boolean, text: String, icon: String, color: String, badge: [Number, String], iconClass: unknownProp, iconPrefix: String, }), setup(props, { slots }) { const route = useRoute(); useParent(ACTION_BAR_KEY); const renderIcon = () => { const { dot, badge, icon, color, iconClass, iconPrefix } = props; if (slots.icon) { return ( {slots.icon()} ); } return ( ); }; return () => (
{renderIcon()} {slots.default ? slots.default() : props.text}
); }, });