如何在 NextJS 的 <style jsx> 标签内评论样式

How to comment styles inside <style jsx> tag in NextJS

在CSS中,可以使用/* */注释掉代码。如何在style jsx in NextJS.I中注释代码,在网上搜索了这个,没有找到。

<style jsx>{`
      table,th,td{
           border: 2px solid black;
      }

      #OOP{
        //height: 10vh;
        /*background-color: #28DE65;*/
  //Both of these comment styles doesn't work inside style jsx
      }
`}</style>

您可以使用 _ 作为前缀,这不是注释,但不会解释属性:

<style jsx>{`
      table,th,td{
           border: 2px solid black;
      }

      #OOP{
        __height: 10vh;
        __background-color: #28DE65;
      }
`}</style>

不是很好的解决方案,但它有效 ;-)

CSS 评论在 <style jsx> 中有效 next.js。你可能有 missed/misconfigured 东西。

演示