【发布时间】:2020-08-05 04:18:16
【问题描述】:
我使用 create-react-app 和 typescript 创建了一个新项目,并在我的项目中添加了一个 sass 文件(在 create-react-app 文档中它说它支持开箱即用的 sass 文件)但我得到了这个我的 sass 文件出错:
Failed to compile.
./src/homepage.style.sass (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/homepage.style.sass)
SassError: Invalid CSS after ".homepage {": expected "}", was "{"
on line 1 of /home/taghi/wt-projects/react-ecommerce/src/homepage.style.sass
>> .homepage { {
-----------^
这是我的 Sass 文件内容:
.homepage {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 80px;
}
.directory-menu {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.menu-item {
min-width: 30%;
height: 240px;
flex: 1 1 auto;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid black;
margin: 0 7.5px 15px;
&:first-child {
margin-right: 7.5px;
}
&:last-child {
margin-left: 7.5px;
}
.content {
height: 90px;
padding: 0 25px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 1px solid black;
.title {
font-weight: bold;
margin-bottom: 6px;
font-size: 22px;
color: #4a4a4a;
}
.subtitle {
font-weight: lighter;
font-size: 16px;
}
}
}
任何帮助将不胜感激
【问题讨论】:
-
SASS 语法是基于缩进的,它不使用大括号......所以只需将文件更改为 .scss 文件
-
好电话,这就是问题所在,它现在正在工作。谢谢@TomFinney
标签: reactjs typescript sass create-react-app