Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经在我的页面中设置了当前主题,
<MudThemeProvider Theme="_currentTheme" /> @code { private readonly MudTheme _currentTheme = new PortalTheme(); }
从另一个组件访问它的最佳方法是什么?我应该创建一个级联属性吗?
您可以使用 CascadingValue 或创建一个单例服务,将其注入到包含对主题的引用的组件中。