用引号反应 TSX 标签参数

React TSX tag params with quotes

在 TSX HTML 标签中使用单引号比使用双引号有什么优势吗?

单引号:

<Table aria-label='simple table'>
  ...
</Table>

双引号:

<Table aria-label="simple table">
  ...
</Table>

根据w3

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ".

所以没有关系,选择你喜欢的风格

解决方法是使用.prettierrc

{
  "semi": false,
  "singleQuote": true,
  "jsxSingleQuote": false
}