[英]Custom Angular library not applying css styles when importing into another project
I've made an Angular library that I'm importing into an outside project.我制作了一个 Angular 库,并将其导入到外部项目中。 The styles I created in the original project however are not showing up when I use the library in the outside project.
但是,当我在外部项目中使用库时,我在原始项目中创建的样式没有显示出来。
Here's the layout of my project:这是我的项目的布局:
-> my-lib
-> src
-> lib
-> components
-> models
-> services
-> styles
-> my_styles.css
In my angular.json file for this project, I've included the .css file in the styles section like:在这个项目的 angular.json 文件中,我在样式部分包含了 .css 文件,例如:
"styles": [
"src/lib/styles/my_styles.css"
]
After I package the project into a custom library, I import it into the outside project:在我将项目打包成自定义库后,我将其导入到外部项目中:
"my-lib": "file:my-lib-1.0.0.tgz"
In the outside project's angular.json within the main project I include the style sheet in the 'styles' section similar to how I did the original project:在主项目的外部项目的 angular.json 中,我将样式表包含在“样式”部分,类似于我做原始项目的方式:
"styles": [
"node_modules/my-lib/styles/my_styles.css"
]
When I run this project however, the styles aren't being applied.然而,当我运行这个项目时,没有应用这些样式。 What exactly am I doing wrong?
我到底做错了什么?
simply you can add your file my_styles.css in assests folder and call it in style.css like this只需将文件 my_styles.css 添加到assests文件夹中,然后像这样在 style.css 中调用它
@import url('./assets/my_styles.css'); @import url('./assets/my_styles.css');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.