【问题标题】:how to change p-table background color when theme changes to dark theme in ngx-admin angular当主题更改为ngx-admin angular中的深色主题时如何更改p表背景颜色
【发布时间】:2021-07-12 01:32:55
【问题描述】:

我正在使用 ngx-admin 模板和我的表。我不使用 ng2-smart-table。 我试图将整个页面更改为深色主题。除表格外,整页更改为暗模式。桌子仍然是白色的。 当主题更改为深色主题时,如何将表格颜色更改为深色主题。 我附上我的问题的屏幕截图。

我需要桌子也必须改变深色主题。我该怎么办?

 themes = [
    {
      value: 'default',
      name: 'Light',
    },
    {
      value: 'dark',
      name: 'Dark',
    },
    {
      value: 'cosmic',
      name: 'Cosmic',
    },
    {
      value: 'corporate',
      name: 'Corporate',
    },
  ];

  currentTheme = 'default';

【问题讨论】:

    标签: angular11 nebular ngx-admin p-table


    【解决方案1】:

    您首先需要研究primeng主题以及如何将它们导入您的项目并加以利用。

    但是为了回答这个问题,因为 ngx-admin 本身并不能处理主题更改时primeng 的所有颜色。您必须订阅星云主题中的主题更改并自己更新表格。

    themeClass: string = 'light-theme';
    
    constructor(private themeService: NbThemeService) {
    this.themeService.onThemeChange()
          .subscribe((theme) => {
          // Here is where you will know which theme is currently applied and you can do logic. For example (if setting theme by class):
          this.themeClass = theme?.name == 'light' ? 'light-theme' : 'dark-theme';
          });
    }
    

    【讨论】:

    • 我在 .css 文件中做了这样的更改。 ::ng-deep .nb-theme-default table { //styles } 它有效。谢谢
    猜你喜欢
    • 2021-03-11
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多