简体   繁体   English

导入css时,角度组件显示错误,没有此类文件或目录

[英]Angular component showing error no such file or directory while importing css

I am creating an angular component and in the assets folder i have pasted all the js and extra css files. 我正在创建一个角度组件,并且在资产文件夹中粘贴了所有js和额外的CSS文件。 But when i am trying to import the css file in a particular component it shows error that no such file or directory found where as when i click ctrl+click it goes to the right path but during compilation it shows this error. 但是,当我尝试在特定组件中导入css文件时,它显示错误,找不到这样的文件或目录,例如当我单击ctrl + click时它会转到正确的路径,但在编译过程中会显示此错误。

I tried including absoulte path but still issue not resolved 我尝试过包括绝对路径,但仍然无法解决问题

import { Component, OnInit } from '@angular/core';

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

  constructor() { }

  ngOnInit() {
  }

}
@import '/src/assets/fonts/font-awesome-4.7.0/css/font-awesome.min.css';

When adding a file as an asset, it makes it available througout your entire application. 将文件添加为资产时,它将使整个应用程序都可以使用它。

This is, for instance, what happens with your style.scss file. 例如,这就是您的style.scss文件所发生的情况。

If you have added it to your assets, then simply consider its entiretity to be available in all of your components. 如果已将其添加到资产中,则只需考虑其完整性即可在所有组件中使用。

This means you can now use all classes of font awesome, in any component template, without worrying about importing it. 这意味着您现在可以在任何组件模板中使用所有超棒的字体类,而不必担心导入它。

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

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