简体   繁体   English

我的css和sass类显示在里面<style>tags in <head> while I was coding in react.js

[英]my css and sass classes are shown inside <style>tags in <head> while I was coding in react.js

I was making react components and everything was good until I see that my sass classes are shown in my result 我正在制作React组件,一切都很好,直到看到结果中显示了我的Sass类

when I view the page source every thing is ok and <body> contains my code inside the root element ,but when I inspect elements there are <style> tags with sass classes inside <head> also my console has no errors. 当我查看页面源代码时,一切正常,并且<body>我的代码包含在root元素内,但是当我检查元素时,在<head>内有带有sass类的<style>标记,我的控制台也没有错误。 I can solve this issue using style{display:none;} but I want to know the reason why this issue happens. 我可以使用style{display:none;}解决此问题style{display:none;}但我想知道发生此问题的原因。

inspect and my result are in this picture 检查,我的结果在这张照片中

That happens when you style your application with .css or .sass files, like the initial ones that come with create-react-app (index.css) . 当您使用.css.sass文件(例如, create-react-app (index.css)的初始文件)对应用程序进行样式设置时,就会发生这种情况。 If you want to style your app and don't want that to show, create .js files and put your css inside, using inline style , for example. 如果您想对应用程序进行样式设置而又不希望其显示,请创建.js文件,然后将CSS放入其中,例如使用内联样式

Example: 例:

在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM