繁体   English   中英

Angular 不能在新生成的组件中使用 Scss

[英]Angular Can not use Scss in new generated component

如下图错误Error1:

在此处输入图像描述

[WDS] 编译时出错。 防止重新加载。
./src/app/products/products.component.sass 模块构建失败(来自./node_modules/sass-loader/lib/loader.js):

这是我的代码:

\\This is my new components product.components.ts
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-products',
  templateUrl: './products.component.html',
  styleUrls: ['./products.component.sass']
})
export class ProductsComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }
}

这是错误

错误 in./src/app/products/products.component.sass 模块构建失败(来自./node_modules/sass-loader/lib/loader.js):
#DIV_1 { ^ Invalid CSS 在 "#DIV_1 {": 预期 "}" 之后,是 "{" in...\src\app\products\products.component.sass(第 1 行,第 9 列)i 「wd编译失败。

我从

styleUrls: ['./products.component.sass']

styleUrls: ['./products.component.css']

这可以解决我的问题。 但我不认为这是允许的答案。 我想使用scss。 然后我可能会将此标记为与我相同并且需要快速修复的人。

您在 a.sass 文件中使用大括号。

如果要使用括号,则需要使用 .scss 扩展名

在此处阅读差异: Sass:语法

暂无
暂无

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

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