我在 Next.js 中使用 AMP 和 CSS 时遇到问题。在我的头部组件中,我有:
<Head>
<style amp-custom>{`
// CSS Here
`}</style>
</Head>
Run Code Online (Sandbox Code Playgroud)
在 HTML 源代码中,它显示为<style amp-custom=""></style><style>(CSS Here)</style>
在控制台中我收到此错误:The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom (transformed)'.
如何在 CSS 和 Next 上使用 AMPHTML 规则?我尝试过的所有其他方法(例如使用 @zeit/next-sass 从文件导入)都会导致 CSS 根本无法渲染。这是我发现的唯一有效版本。