import { use } from '../utils'; import { inherit } from '../utils/functional'; import Info from '../info'; // Types import { CreateElement, RenderContext } from 'vue/types'; import { DefaultSlots } from '../utils/use/sfc'; export type IconProps = { tag: keyof HTMLElementTagNameMap | string; name: string; size?: string; color?: string; info?: string | number; classPrefix: string; }; export type IconEvents = { onClick?(event: Event): void; }; const [sfc] = use('icon'); function isImage(name?: string): boolean { return name ? name.indexOf('/') !== -1 : false; } function Icon( h: CreateElement, props: IconProps, slots: DefaultSlots, ctx: RenderContext ) { const urlIcon = isImage(props.name); return ( {slots.default && slots.default()} {urlIcon && } ); } Icon.props = { name: String, size: String, color: String, info: [String, Number], tag: { type: String, default: 'i' }, classPrefix: { type: String, default: 'van-icon' } }; export default sfc(Icon);