【发布时间】:2020-04-15 13:48:06
【问题描述】:
我正在尝试将 css 文件导入到 react 应用程序中,但我所拥有的只是
模块解析失败:意外令牌 (1:6) 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。见https://webpack.js.org/concepts#loaders
我尝试了所有方法,包括有关此主题的其他 StackOverflow 问题,但没有一个对我有用
我的反应代码:
import React from 'react'
import './components/App.css'
class App extends React.Component {
render() {
return (
<div className='container'>
<title>
Chamados
</title>
<section className='main-wrapper'>
<header>
<h1>LOGIN</h1>
</header>
<form>
<input type="text" name="user" id="user" placeholder='Usuário' focus autoComplete='no'/>
<input type="password" name="pass" id="pass" placeholder='Senha'/>
<input type="submit" value="SIGN IN" id='bSignIn'/>
</form>
</section>
</div>
)
}
}
export default App
我的 CSS 代码:
header{
text-align:center;
margin-top:30%
}
.container{
margin:0px;
padding:0px
}
.main-wrapper{
height:450px;
width: 300px;
padding: 40px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background-image: linear-gradient(#FFFAF0,#E6E6FA);
align-items: center;
border-radius:5px;
box-shadow: 1px 1px 15px #b3b3b3 !important;
}
.form{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
input[type = "text"], input[type = "password"]{
height:30px;
width:250px;
border: none;
outline:none;
border-radius: 0;
background:none;
display:block;
margin: 20px auto;
text-align:center;
border-bottom:2px solid #adadad;
}
#bSignIn{
outline:none;
border: 0 none;
border-radius: 0;
height:50px;
width:250px;
background-image: linear-gradient(to right,#ADD8E6,#E0FFFF)
}
【问题讨论】:
-
您必须共享您的 webpack 配置而不是您的应用程序。错误是报告您 webpack 无法处理 CSS 资源,因此您缺少加载程序。
-
在哪里可以找到这个 webpack 文件?