简体   繁体   English

如何从公用文件夹中导入组件的样式表。 和组件文件在src / components / files中,那么我的app.js看起来像

[英]how can import style sheet for components from public folder. and components files are in src/components/files then my app.js look like

I'm new to ReactJS. 我是ReactJS的新手。

When I load my page, I get this error. 加载页面时,出现此错误。 Please advice me how to import style for component from public folder. 请告诉我如何从公用文件夹导入组件的样式。

import React, { Component } from 'react';
import Header from './components/Header'; 
import './App.css'; 
import  './public/dist/css/AdminLTE.min.css';   
class App extends Component {  
   render() {   
     return ( <div className="App"> 
        <Header />      
        </div>    
     );  
   } 
}
export default App;

Thanks in advance. 提前致谢。

You should not put css files in public folder because webpack doesn't read the public folder it will only read the files inside the src folder Public folder(ReactJS) . 您不应该将css文件放在公共文件夹中,因为webpack不会读取公共文件夹,它只会读取src文件夹公共文件夹(ReactJS)中的文件 So it is better to add your stylesheets in src folder & access it from there. 因此,最好将样式表添加到src文件夹中并从那里访问它。

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

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