简体   繁体   English

如何评论将由webpack编译的React

[英]How to comment in react that will be compiled by webpack

It's all in the title really, I've try'ed: 我试过了,实际上是标题中的所有内容:

/*Comment here*/

and

//Comment here

But both show up on the webpage. 但是两者都显示在网页上。

The only way to add comments in JSX is to use {/* ... */} syntax, for example: 在JSX中添加注释的唯一方法是使用{/* ... */}语法,例如:

...
<div>
  {/* A JSX comment */}
</div>
...

The HTML comments <!-- ... --> do not work, plain JS comments // and /* ... */ do not work too. HTML注释<!-- ... -->不起作用,普通的JS注释///* ... */也不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM