freeCodeCamp/guide/chinese/certifications/front-end-libraries/react/add-comments-in-jsx/index.md

30 lines
568 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Add Comments in JSX
localeTitle: 在JSX中添加注释
---
## 在JSX中添加注释
您可以像在Javascript `/* some JS code */`那样使用代码块进行注释但它们需要用花括号括起来在JSX中添加注释 例如:
* 单行评论:
```jsx
{/*<h1>Hanoi University of Science</h1>*/}
```
* 多行评论:
```jsx
{/*
<h1>Hanoi University of Science</h1>
<p>Falculty of Mathematics, Mechanics and Informatics</p>
*/}
```
注意您不能在JSX中使用HTML注释如下所示
```html
<!-- not working -->
```