[英]Next.js: __next div causing css style failure
I am trying to move my old static HTML project into Next.js, but the extra我正在尝试将我的旧 static HTML 项目移动到 Next.js 中,但是额外的
<div id="__next">
is blocking some of class in my css stylesheet(eg. body
> section
).在我的 css 样式表(例如
body
> section
)中阻止了一些 class 。
I tried to remove the extra div in inspect mode and it works.我试图在检查模式下删除额外的 div 并且它有效。 Just wondering how to remove it from the rendering?
只是想知道如何从渲染中删除它? Thanks a bunch.
谢谢一堆。
For class based react (can also use in constructor, componentWillMount will be deprecated)
对于基于 class 的反应(也可以在构造函数中使用,componentWillMount 将被弃用)
componentWillMount() {
let tar = document.getElementById('__next');
tar.parentNode.innerHTML = tar.children[0].innerHTML;
}
For react hook (Functional component)
对于反应钩子(功能组件)
useEffect(()=>{
let tar = document.getElementById('__next');
tar.parentNode.innerHTML = tar.children[0].innerHTML;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.