如何修复组件位置从底部开始,然后在刷新页面时移动到react JS中的正常位置
我的组件具有侧边栏和内容,如下所示。
当页面刷新时,第一次加载组件内容下面如下所示,在瞬间,组件恢复正常。
我在每个组件中使用Module.css。有这样的结构:
component
|___Sidebar
| |___index.tsx
| |___index.module.css
|___Content
|___index.tsx
|___index.module.css
谁能解释发生了什么?发生这种情况是因为我使用的是CSS文件夹结构,例如会导致样式迟到吗? 您如何看待这个问题可以解决?
I have a component that has a sidebar and content as shown below.
When the page is refreshed, the first time the component content is loaded below as shown below and in an instant, the components are back to normal.
I use module.css in every component. With a structure like this:
component
|___Sidebar
| |___index.tsx
| |___index.module.css
|___Content
|___index.tsx
|___index.module.css
Can anyone explain what happened? Is this happening because I'm using css folder structure like that which causes styles to be late to read?
How do you think this problem can be solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择之一是将CSS文件加载到index.js或app.js文件中,该文件是应用程序中最重要的组件。然后,您可以使用DOM事件添加类似的组件。目前,由于您没有共享任何代码,因此很难复制该问题。但是我建议值得尝试一下。确保在index.js文件中添加CSS文件
One of the option is to load the CSS files in the index.js or app.js file which is the top most component in your app. Then you can use the dom event to add the component like below. Currently it is difficult to reproduce the issue since you haven't shared any code. But I would suggest worth giving this a try. Make sure you add the CSS files in index.js file