sass - 无法通过页面 css 文件向“body”标签添加值
问题描述
在我的 Angular 应用程序中,我正在向 body 添加一个类名,例如:
ngOnInit() {
this.store.updatePageClass('page-quoteCart');
}
在 page.css 我正在写一个类,如:
@media only screen and (min-width: 320px) and (max-width: 620px) {
.page-quoteCart{
border:2px solid red; //but not added
}
}
但没有得到输出。assets
如果我在有效的文件夹中的 style.css 中编写相同的内容。这里有什么问题?
如何根据页面编写css?
解决方案
请encapsulation: ViewEncapsulation.None
在您的html中添加。它将解决您的问题。
例如,在您更新之后encapsulation: ViewEncapsulation.None
- 您的组件文件将如下所示:
import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'xxxxx',
templateUrl: 'xxxxx.html',
styleUrls: ['xxxx.scss'],
encapsulation: ViewEncapsulation.None
})
推荐阅读
- sql - 在 Microsoft Dynamics 中使用 executeQueryWithParameters 加入 x++/sql 语句时,如何获得正确的语法?
- javascript - 在 Typescript 中读取强类型的 yaml 文件?
- php - 在android中将图像作为BLOB上传到SQL
- angular - 将本地 Angular cli 版本升级到全局
- html - 使用 HTML 生成的 pdf 第二页上的重叠标题
- php - 如何在前端显示 WooCommerce 变体 ACF 字段
- postgresql - 我们可以在将数据从 s3 导入 RDS postgres 时进行转换吗?
- python - 我收到此错误 ValueError: int is not allowed for map key while using Spacy and Msgpack
- r - tabsetPanel / tabPanel R 闪亮的工具提示
- c - 未定义的 _write 引用,在库中实现