【问题标题】:How to set background colour using NativeScript theme v3如何使用 NativeScript 主题 v3 设置背景颜色
【发布时间】:2021-06-20 18:49:09
【问题描述】:

我正在尝试解决如何使用 NativeScript 主题 v3 并坚持根据主题设置背景颜色这样简单的事情:

这是我正在尝试的(使用recommended colorize mixin):

@import "~@nativescript/theme/scss/variables";

.mything {
    @include colorize($background-color: primary);
}

但这总是将背景设置为暗,并且在我切换主题时没有效果。

如果我尝试以下代码,它总是红色的,也遵循推荐的方法:

.mything {
    background-color: red;
    .ns-dark & {
        background-color: green;
    }
}

我做错了吗?

【问题讨论】:

    标签: themes nativescript


    【解决方案1】:

    我有 just found a solution of sorts 解决了这个问题,因为我可以在切换主题时让它工作 - 但这似乎违背了拥有 colorize 混合等的意义。

    .mything {
        background-color: red;
    }
    
    :host-context(.ns-dark) .mything {
        background-color: green;
    }
    

    或者:

    .mything {
        background-color: red;
        :host-context(.ns-dark) & {
            background-color: green;
        }
    }
    

    我在此处发布此内容,以防其他人对此感到困惑而没有其他人回答。

    【讨论】:

      猜你喜欢
      • 2012-07-31
      • 2015-06-29
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 2010-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多