angular - 组件角度中加载 styleUrls 的条件
问题描述
我想在 styleUrls 中使用多 CSS
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [condition 'if' for Which load css]
})
我累了
解决方案
您可以在内部使用三元运算符:
const url1 = './foo.css';
const url2 = './bar.css';
let condition = true
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [condition ? url1 : url2]
})
推荐阅读
- optaplanner - 我们正在尝试为动物收容所构建一个简单的 OptaPlanner 解决方案,但效果不佳
- javascript - 未捕获的 ReferenceError:AI 未在 Object.play.AIPlay 中定义
- react-admin - 在 App.js 中访问 redux 存储中的值
- java - 使用 Java Swing GroupLayout 从 SQL 数据库创建数据表
- mysql - 如果时间戳不存在,Mysql Query 不返回值
- angular - 错误类型错误:labels.slice 不是使用@ngx-translate Angular 的函数 barChartLabels 图
- android - 如何使用 Appium + Robot 框架在 android 中获得隐形视图?
- python - 使用 Python CGI 时,有没有办法以与默认格式不同的格式输出 bash 命令结果
- sql-server - PostgreSQL 9.4 & 12.1,在 SQL 错误后丢失锁
- java - Spring-Boot 应用程序中未保留时区更改