2

我正在使用create-react-app并且在标记模板文字中有 JavaScript 并且它被注释掉的地方(如下例所示),它仍然会运行(在这种情况下它将应用重置)。

为什么会发生这种情况,如何预防?

import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";

export default createGlobalStyle`
  /* the following line will run even though it's commented out */
  /* ${reset} */
`

似乎这是create-react-app中的 Webpack/Babel 配置的问题?因为我无法在这个沙盒上复制它:

https://codesandbox.io/s/p7qx411xvq

使用:styled-components@4.2.0

4

0 回答 0