-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
icon component be a string from server #132
Comments
https://github.com/antfu/unplugin-icons#custom-icons You can write your down function to request them. |
@antfu Sorry, I may not have made it clear, the menu data object like [{
icon: 'xxx',
name: 'dashboard',
},
{
icon: 'yyy',
name: 'signin',
},
] and in jsx,how to import ionify icon? const icon = menu.icon
<Icon name={icon} /> this component only can load static? <XXX /> another lib https://github.com/antfu/unocss/tree/main/packages/preset-icons may not be easy to use the solution of this library, |
Sorry no if they can't be determined at build time #5 You can consider using Iconify's runtime |
I think this is indeed impossible, because the dynamic icon obtained from the server is unpredictable, so it is impossible to have a local icon. Maybe the official api from ionify is the best way <Icon name={icon} {...rest} /> |
@antfu finally,component like const Icon: FC<...> = (props) => {
// it's by unplugin-icons
if (props.type === IconType.IONIFY) return <Ionify {...omit(props, ['children'])} />;
// others
if (props.type === IconType.Antd) return <AntdIcon {...props} />;
if (props.type === IconType.ICONFONT) return <IconFont {...props} />;
return <SvgIcon {...(props as SvgPropsType)} />;
};
export default Icon; |
If i have an menu config from server,the icon is string not component,how to use it?like this
The text was updated successfully, but these errors were encountered: