【问题标题】:Angular Can not use Scss in new generated componentAngular 不能在新生成的组件中使用 Scss
【发布时间】:2022-01-24 21:32:19
【问题描述】:

如下图错误 错误1:

[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() {
  }
}

这里是错误

./src/app/products/products.component.sass 中的错误 模块构建失败(来自 ./node_modules/sass-loader/lib/loader.js):
#DIV_1 { ^ “#DIV_1 {”后的无效 CSS:预期为“}”,为“{” 在 ...\src\app\products\products.component.sass (第 1 行,第 9 列) i 「wdm」: 编译失败。

【问题讨论】:

  • 你能分享你的 products.component.sass 吗?
  • 我认为 scss 没有任何问题,因为第一行有错误,甚至我在这里只放了一行或任何东西。它错误。 #DIV_1 { 块大小:10260.9px; }

标签: html css angular sass


【解决方案1】:

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

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

在此处阅读差异:Sass: Syntax

【讨论】:

    猜你喜欢
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 2021-05-08
    • 2022-06-14
    • 2022-10-02
    • 2018-09-24
    相关资源
    最近更新 更多