Why/How 此代码在 ES6 (React) 中有效吗

Why/How does this code works in ES6 (React)

我正在学习 React 课程并遇到了他们从 styled-components 导入组件的课程,但对我来说奇怪的是第 4 行他们使用反引号插值而不将其括在括号中并且它似乎反引号和 styled.header.

之间不应该有任何 space

这就是所谓的 Tagged Template Literals,ES6 中的一个新特性。

您可以在 the styled-components docs and this article 中阅读更多相关信息。