React创建应用程序生产构建和IE11中的CSS变量

发布于 2025-01-20 20:18:16 字数 204 浏览 2 评论 0原文

我想知道如何在生产版本中删除 CSS 变量。事实上,我需要为 IE11 构建一个不支持 CSS 变量的项目。我的项目是使用 React Create App 创建的,我无法执行 npm run pop。如何设置生产版本,以便在样式的初始心率中而不是变量,而是它们的值?

不要提供 css-vars-ponyfill,在 IE11 中加载页面需要很长时间。

I would like to know how to get rid of CSS variables in a production build. The fact is that I need to build a project for IE11 in which CSS variables are not supported. My project was created using React Create App and I can't do npm run eject. How can you set up a production build so that in the initial heart rate of the style, instead of variables, there would be their values?

Don't offer css-vars-ponyfill, it takes a very long time to load a page in IE11.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心病无药医 2025-01-27 20:18:16

让 CSS 变量在 IE 中工作的唯一方法是使用 polyfill。如果您不想使用 css-vars-ponyfill,可以尝试 ie11CustomPropertiescss-variables-polyfill

如果你不想使用polyfill,我认为你只能手动编辑CSS样式来添加CSS后备来支持IE11。像这样的事情:

body {
  --text-color: red;
}
body {
  color: red;
  color: var(--text-color);
}

The only way to make CSS variables work in IE is using a polyfill. If you don't want to use css-vars-ponyfill, you can try ie11CustomProperties or css-variables-polyfill.

If you don't want to use a polyfill, I think you can only edit the CSS styles manually to add CSS fallbacks to support IE11. Something like this:

body {
  --text-color: red;
}
body {
  color: red;
  color: var(--text-color);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文