Skip to content
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能自动转为图标就更好了。现在需要loop一次转为对象才可以显示图标。 #8301

Closed
oxygen-xx opened this issue Apr 2, 2021 · 5 comments

Comments

@oxygen-xx
Copy link

🥰 需求描述

现在如果从服务器取数据形成菜单,需要再Loop一次,把菜单中的图标string转对象才可以生成图标,这样很不方便,如果能根据string自动转为系统'@ant-design/icons'中的图标就更好了。现在如果是根据路由配置生成的菜单,就可以根据字符串形成图标,但是从后端取数据形成的动态菜单就需要再转一次,不方便。

🧐 解决方案

像路由形成菜单一样,可以根据string转为图标。

🚑 其他信息

@oxygen-xx oxygen-xx changed the title 👑 [需求]如果菜单中的icon能识别字符串,自动转为相对应的图标就更好了 👑 [需求]如果从后端取数据而生成的菜单中的icon能自动转为图标就更好了。现在需要loop一次转为对象才可以显示图标。 Apr 2, 2021
@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Apr 5, 2021

专门去掉这个功能的,图标库有 3m 多,你只用几个图标,如果做得灵活了,就没 treeshking 了

@oxygen-xx
Copy link
Author

@chenshuai2144 ,现在根据route自动生成的菜单就可以实现图标的自动显示,不知道实现原理是不是一样的,如果都没有性能负担的话,还是把动态菜单也补充上这个功能较好。

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Apr 8, 2021

route 是不会动态变化的,所以扫描了一下配置,只 import 了 router 配置的 icon

@chengzi-code
Copy link

问下大佬,你是怎么loop转换的,可以贴个代码吗

@chenshuai2144
Copy link
Collaborator

@chengzi-code #8101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants