【问题标题】:How to access to the current theme in MudBlazor component?如何访问 MudBlazor 组件中的当前主题?
【发布时间】:2021-12-15 19:07:54
【问题描述】:

我已经在我的页面中设置了当前主题,

<MudThemeProvider Theme="_currentTheme" />
@code
{
    private readonly MudTheme _currentTheme = new PortalTheme();
}

从另一个组件访问它的最佳方式是什么?我应该创建级联属性吗?

【问题讨论】:

    标签: themes mudblazor


    【解决方案1】:

    您可以使用 CascadingValue,也可以创建一个单例服务,将其注入到包含对主题的引用的组件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      • 2020-11-23
      • 2019-11-28
      • 2023-04-03
      • 2021-03-21
      • 1970-01-01
      • 2021-02-11
      相关资源
      最近更新 更多