我在 angular 4 中创建了一个空白元素,我正在尝试设计它,但是当我添加 sass 并运行元素时,sass 无法正常工作,我收到此错误
body{
h1{
color : red;
}
}
^
Invalid CSS after "body{": expected "}", was "{"
in C:projectname/src\styles.sass (line 1, column 6)
我的index.html代码是
<body>
<h1>Here</h1>
</body>
任何帮助将不胜感激
最佳答案
根据您的错误消息 (C:projectname/src\styles.sass) 您似乎正在为 SCSS
文件使用 .sass
扩展名。将文件名更改为 styles.scss
。
Sass
和 SCSS
使用两种不同且不兼容的语法。
There are two syntaxes available for Sass. The first, known as SCSS (Sassy CSS) and used throughout this reference, is an extension of the syntax of CSS. This means that every valid CSS stylesheet is a valid SCSS file with the same meaning. This syntax is enhanced with the Sass features described below. Files using this syntax have the .scss extension.
The second and older syntax, known as the indented syntax (or sometimes just “Sass”), provides a more concise way of writing CSS. It uses indentation rather than brackets to indicate nesting of selectors, and newlines rather than semicolons to separate properties. Files using this syntax have the .sass extension.
关于css - 无法在 Angular 4 中添加 Sass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56654774/