NextJS和Uikit框架:Prop className不匹配

发布于 2025-01-17 19:16:45 字数 588 浏览 1 评论 0原文

我正在使用 uikit Framework 在我的Next.js项目中。

在此html代码中:

<div className="uk-child-width-1-2@m" data-uk-grid>...</div>

它给出此错误:

Warning: Prop `className` did not match.
Server: "uk-child-width-1-2@m uk-grid uk-grid-stack"
Client: "uk-child-width-1-2@m"

实际上,data-uk-grid添加了2个类(uk-riduk-rid-stack < /code>)通过其JS到该元素。因此,服务器和客户端的类列表(由于服务器端渲染)存在差异,NextJS给出了此错误。

有人可以解决这个问题吗?

I'm using uikit framework in my next.js project.

In this HTML code:

<div className="uk-child-width-1-2@m" data-uk-grid>...</div>

It gives this error:

Warning: Prop `className` did not match.
Server: "uk-child-width-1-2@m uk-grid uk-grid-stack"
Client: "uk-child-width-1-2@m"

In fact, the data-uk-grid adds 2 classes (uk-grid and uk-grid-stack) to the element by its js. So there is a difference in the list of classes in Server and Client (due to server side rendering), and Nextjs gives this error.

Does anyone have a solution to this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文