簡體   English   中英

IE11 中的 React Create Application 生產構建和 CSS 變量

[英]React Create Application production build and CSS variables in IE11

我想知道如何在生產版本中刪除 CSS 變量。 事實上,我需要為 IE11 構建一個項目,其中不支持 CSS 個變量。 我的項目是使用 React Create App 創建的,我無法執行 npm run eject。 您如何設置生產構建,以便在風格的初始心率中,而不是變量,會有它們的值?

不要提供css-vars-ponyfill ,在 IE11 中加載頁面需要很長時間。

使 CSS 變量在 IE 中工作的唯一方法是使用 polyfill。 如果你不想使用 css-vars-ponyfill,你可以嘗試ie11CustomPropertiescss-variables- polyfill 。

如果你不想使用polyfill,我認為你只能手動編輯CSS styles 添加CSS fallbacks來支持IE11。 像這樣:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM