我们是否能够为 CSS 语句编写 JavaScript 等效对象?

Are we able to compose JavaScript equivalent objects for CSS statements?

我开始使用 React 和 Material UI,我遇到了样式。他们使用一种叫做 CSS-in-JS 的东西。对于在 JavaScript 中使用 camelCase 而不是 kebab-case 的属性有点困惑。

在下面的 link 中,CSS Properties Reference,我们可以看到 CSS 属性的所有 JavaScript 等价物。我的问题是,我们是否仅限于 JavaScript 等效项的列表?我们可以为它的 CSS 对应物 column-rule-style 做类似 columnRuleStyle 的事情吗?

请告诉我您的想法。感谢您的帮助!

这不是一个 React 约定,但既然你提到要开始 React,那么 React 必须说的是:

https://reactjs.org/docs/dom-elements.html#style

The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes.

AFAIK,是的,几乎所有*支持的CSS规则都被支持,在 JS 中使用驼峰式大小写。

* 在我从事 React 的 3 年里,我还没有找到一个不存在的。