我在Next.js中遇到AMP和CSS的问题。在我的头部,我有:
<Head>
<style amp-custom>{`
// CSS Here
`}</style>
</Head>
在HTML源代码中显示为<style amp-custom=""></style><style>(CSS Here)</style>
在控制台中,我收到此错误:The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom (transformed)'.
我如何使用AMPHTML在CSS和Next上的规则?我尝试过的所有其他方法(例如,使用@ zeit / next-sass从文件中导入)都会导致CSS根本无法呈现。这是我找到的唯一可用的版本。
...必须为:<style jsx>...</style>
。我整天都在寻找解决方法的非常愚蠢的错误。 :/
尝试:
<style jsx amp-custom>
`
... my css
`
</style>
我刚刚对其进行了测试,效果很好。不是最佳方法,NextJS应该记录在某处添加css的方法。