简体   繁体   中英

Angular Can not use Scss in new generated component

As shown below Error Error1:

在此处输入图像描述

[WDS] Errors while compiling. Reload prevented.
./src/app/products/products.component.sass Module build failed (from./node_modules/sass-loader/lib/loader.js):

This is my code:

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

Here is error

ERROR in./src/app/products/products.component.sass Module build failed (from./node_modules/sass-loader/lib/loader.js):
#DIV_1 { ^ Invalid CSS after "#DIV_1 {": expected "}", was "{" in...\src\app\products\products.component.sass (line 1, column 9) i 「wdm」: Failed to compile.

I change from

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

to

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

This can fix my problem. But I don't think this is allowed answer. I would like to use scss. Then I might mark this for someone who face the same as me and need quick fixed.

You are using curly brackets in a.sass file.

If you want to use brackets you need to use.scss extension

Read the difference here: Sass: Syntax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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