Angular 6 在 angular.json 中加载 css 文件夹 [英] Angular 6 load css folders in angular.json

查看:29
本文介绍了Angular 6 在 angular.json 中加载 css 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 html 模板转换为 angular 应用程序.我有一个名为 plugins 的 css 文件夹和 img 文件夹.

I am trying to convert my html template into angular app. I have a css folder called plugins and img folder.

当我添加时:

 "styles": [
          "src/assets/plugins/listtyicons/style.css",
          "src/assets/plugins/jquery-ui/jquery-ui.min.css",
          "src/assets/plugins/bootstrap/css/bootstrap.min.css",
          "src/assets/plugins/plugins/isotope/isotope.min.css",
          "src/styles.css"

        ]

angular.json 文件中的这段代码我在尝试启动 angular 应用程序时遇到错误.我已将插件文件夹放在资产文件夹中.我收到此错误:

this code in angular.json file I am getting error when trying to start angular app. I have put my plugin folder inside assets folder. I am getting this error:

 ERROR in multi ./src/assets/plugins/listtyicons/style.css 
./src/assets/plugins/jquery-ui/jquery-ui.min.css ./src/assets/plugins/bootstrap/css/bootstrap.min.css ./src/assets/plugins/plugins/isotope/isotope.min.css ./src/styles.css
Module not found: Error: Can't resolve 
'/Users/nilay/angular/bes/src/assets/plugins/plugins/isotope/isotope.min.css' 
in '/Users/nilay/angular/bes'

我不知道为什么会出现此错误.

I don't know why am I getting this error.

推荐答案

angular 6中,你必须在src/style.css中添加only代码>(而不是angular.json):

In angular 6 you have to add only in src/style.css (instead angular.json):

@import "assets/plugins/listtyicons/style.css";
@import "assets/plugins/jquery-ui/jquery-ui.min.css";
@import "assets/plugins/bootstrap/css/bootstrap.min.css";
@import  "assets/plugins/plugins/isotope/isotope.min.css";

angular.json

"styles": [
          "src/styles.css"
        ]

这篇关于Angular 6 在 angular.json 中加载 css 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆