💥 1.2.0-beta.1 Breaking Change #4060
Replies: 7 comments 11 replies
-
请问使用el-icon 如何动态加载图标? |
Beta Was this translation helpful? Give feedback.
-
不太清楚为何开发团队会做出这样的决定,但这种破坏性改动的影响太大。 同样存在 @LeonTheProfessional 提到的场景,对于按名称匹配的图标,按需自动加载不太行。 如果可能的话,我会推荐 SVG Sprites 这种方案。简要概括如下:
|
Beta Was this translation helpful? Give feedback.
-
element plus基本是在内网环境下使用,对体积的敏感度不高吧…… 还不如利用浏览器缓存,单独的静态资源不更好么? |
Beta Was this translation helpful? Give feedback.
-
正常的开发不应该是兼容的吗?为什么把font-icon给去除了,限制我所有组件的icon都不显示了,气死我了,我还不知道怎么修改。 |
Beta Was this translation helpful? Give feedback.
-
对于这个改动我是很欢迎的,Font Icon的扩展性确实不好,且显示不够锐利。对于上面有同学不理解,还是要自己看升级文档啊。 |
Beta Was this translation helpful? Give feedback.
-
75kb就痛点了。。。到现在还没有稳定版不算痛点吗,大问题不解决去搞小问题? |
Beta Was this translation helpful? Give feedback.
-
75KB。。。。 还是基于element-ui源码魔改element-plus中的组件吧 |
Beta Was this translation helpful? Give feedback.
-
1.2.0-beta.1 带来的破坏性变动 | Breaking change introduced in 1.2.0-beta.1
FontIcon
| Deprecation ofFontIcon
epic: deprecation of icon font #3492Shoutouts
为什么带来这些变动 | Breaking change explained.
移除 FontIcon | Deprecation of FontIcon
从 ElementUI 2.x 以来,Element 都在使用 FontIcon 作为组件内图标的展示,但这带来诸多问题:
体积问题 | bundle sizes
为了使用 Element Plus 内置的图标,用户往往需要引用一个 ~75KB 的字体文件,以及 1 个额外的网络请求,这个在大多数情况下属于完全不需要的开销,对体积以及首页加载速度很在意的用户来说,这属于是一个长久的痛点。
For using Element Plus built-in icons, users will need to import a font file ~75KB, in addition to 1 external network request, under most circumstances this is not necessary, for those who cares about the first screen loading and the bundle size this is a long existed pain point.
我们可以通过这个表格来查看这次的变化带来的体积减小程度 | We can know how much size reduction we have in this change
性能问题 | performance
由于这次的改动,所有的 Font Icon 都被改为了 Inline Vue SVG 组件,也就是说所有的组件都是跟随你的打包代码一起放在同一个请求内,所以不会产生额外的网络请求去请求字体文件。所以也不会带来网络请求失败导致字体渲染不出来的小方块。
Per this change, all Font Icon was replaced with Inline Vue SVG component, meaning that all the SVG icons will be bundled into your code, it will not require an extra network request for the font file, which can avoid being not able to render the icon due to network failure.
可访问性 | a11y
Copyright to https://www.lambdatest.com/blog/its-2019-lets-end-the-debate-on-icon-fonts-vs-svg-icons/
可扩展性 | scalability
在这次的改动前,对于 Element Plus 里带有图标的组件而言,如果用户想自定义图标,那么便需要用户通过设置一个如
icon-class
的属性来提供一个对应的字体类名来设置,如:el-icon-edit
,对于那些不想要使用 Element Plus 自带图标的同学,将需要再额外引入一个字体文件,这将会带来额外的开销,对于很多用户来说这都是很不必要的。Before this change, for those components with icons, if user wants to put another icon into the component, it will require the user to set the attribute like
icon-class
to give it a name represent the co-responding icon such as:el-icon-edit
, for those who doesn't want the built-in icons, they will be needed to import an extra Font Icon file which is unnecessary.在这次改动后,用户可以通过提供一个 Vue 组件的方式来为组件传递一个自己想要的图标,这大大的提高了组件的可扩展性,并且你还可以通过 Vue 组件为你的图标提供各种操作空间。如:
After this change, you can pass down a Vue component for getting one of your desired icon, it dramatically increased the scalability for all components with icons, you can also apply actions to your Vue component, for example:
对于哪些 API 的变化请看下面的表格
You can checkout the table below to know the API changes
旧版字体文件 | Backup icon font file
您可以在这里下载旧版本的字体文件来让老项目保持兼容 Download backup icon font file here.
https://unpkg.com/element-plus@1.1.0-beta.24/theme-chalk/base.css
https://unpkg.com/browse/element-plus@1.1.0-beta.24/theme-chalk/fonts/
发布包内容变化 | Release bundle breaking changes
发布包的内容变化可以在 #4018 (comment) 查看
You can checkout the changes for releasing bundle changes at: #4018 (comment)
兼容性变化 | Compatibility breaking changes
兼容性变化可以在 #4058 (comment) 查看
You can checkout the changes for compatibility changes at: #4058 (comment)
下一步 | Next step
相信很多人都在吐槽为什么 Element Plus 的中文文档做的这么差,诸如此类的。我们已经完善了中文文档的内容。如有翻译问题各位也可以通过 Crowdin 向我们贡献文档内容,我们的目标从来就只有把 Element Plus 做得更加好用,感谢大家一直的支持以及耐心 🙏
Beta Was this translation helpful? Give feedback.
All reactions