-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Feature Request] [plugin-icons] <Icon /> 组件支持别名 / aliasing <Icon /> #12178
Comments
为了按需的自动生成最少 icon 的 svg 内容,目前实现是固定扫描 按你这个情况来看,组件名字在 jsx 里就可以是任意的了,你认为有什么比较好的方式确认这个组件是 icon 组件吗,或者针对你这个 SC 的 case 有什么解决方案吗。 |
需要静态分析;不过一旦出现别名,可能的写法就无穷尽,所以只能支持有限并且常用的写法:
实现成本可能会很高 或许直接在文档里声明这个方案的原理和注意事项? |
如果你需要用 SC 包裹,可以写成: import { Icon as UmiIcon } from 'umi'
const Icon = styled(UmiIcon)`
// ...
` 这样就符合扫描规则了。 欢迎 PR 添加组件使用时名字必须为 另外你是从哪里了解到 icons 这个功能的?这个功能并没有很多的篇幅介绍,除了 蚂蚁 or 集团内 之外使用的人应该很少。 |
有是有,但我感觉文档本来乱糟糟的,目测没人会从一大堆选项里面找到这个 icons 的小区域 - - |
暂无支持复杂场景下的 Icons 分析功能。 请先暂时先用你“反过来”别名的解决方法,如果有更好的方案可以 PR ❤️ |
对于
plugin-icons
,当Icon
组件通过别名被使用时,对本地图标的使用在开发时或是编译时都不再被编译器检测到(除非显式地在include
中提供)正常情况下:
别名的一个例子是使用 styled-components 为
Icon
组件提供样式:目前的一个 workaround 是将别名反过来:
是否有可能支持此种别名用法(在合理的范围之内)?
The text was updated successfully, but these errors were encountered: