Next.JS + AMP CSS [英] Next.JS + AMP CSS

查看:34
本文介绍了Next.JS + AMP CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Next.js 中遇到了 AMP 和 CSS 问题.在我的头部组件中,我有:

I'm having trouble with AMP and CSS in Next.js. In my head component I have:

<Head>
    <style amp-custom>{`
        // CSS Here
    `}</style>
</Head>

在 HTML 源代码中,它显示为 <style amp-custom=""></style><style>(CSS Here)</style>

In the HTML source it shows up as <style amp-custom=""></style><style>(CSS Here)</style>

在控制台中,我收到此错误:标签style amp-custom (transformed)"中缺少强制属性amp-custom".

In the console I get this error: The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom (transformed)'.

我如何使用 AMPHTML 对 CSS 和 Next 的规则?我尝试过的所有其他方法(例如使用@zeit/next-sass 从文件导入)都会导致 CSS 根本无法呈现.这是我找到的唯一可用版本.

How can I work with AMPHTML's rules on CSS and Next both? Every other method I've tried (such as importing from a file using @zeit/next-sass) causes the CSS to not be rendered at all. This is the only working version I've found.

推荐答案

...它必须是: