【发布时间】:2020-05-18 09:20:56
【问题描述】:
MatBlazor 文档说“要为所有应用程序应用主题,您可以在 MainLayout.razor 或 App.razor 中使用 MatThemeProvider”
这个例子的信息很薄。
将代码 sn-p 添加到 MainLayout.razor 或 App.razor 时它不起作用。
我得到的错误是 “InvalidOperationException:路由器组件需要参数 Found 的值。”
如何为整个应用应用主题?
App.razor
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<p>Determining session state, please wait...</p>
</Authorizing>
<NotAuthorized>
<Unauthorised />
</NotAuthorized>
</AuthorizeRouteView>
<MatThemeProvider Theme="@theme">
<Router AppAssembly=typeof(Pages.Dashboard).Assembly />
</MatThemeProvider>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
@code
{
MatTheme theme = new MatTheme()
{
Primary = MatThemeColors.Orange._500.Value,
Secondary = MatThemeColors.BlueGrey._500.Value
};
}
【问题讨论】:
-
The Router component你确定这是关于 matblazor 的吗?请说明您添加MatThemeProvider的方式和位置,但似乎还有另一个问题 -
查看更新的代码。如果我删除
那么一切正常。 -
将其放入
MainLayout并将其从您在问题中更新的代码中删除时会怎样? -
同样的事情 - 不知道我怎么弄错了!