在 MainLayout.razor 或 App.razor 中添加 MatBlazor MatThemeProvider
Adding MatBlazor MatThemeProvider in MainLayout.razor or App.razor
MatBlazor 文档说 "To apply theme for all application you can use MatThemeProvider in MainLayout.razor or App.razor"
该示例的信息量非常少。
将代码片段添加到 MainLayout.razor 或 App.razor 时不起作用。
我得到的错误是
"InvalidOperationException: The Router component requires a value for the parameter 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
};
}
你能试试这个吗?
<MatThemeProvider Theme="@theme">
<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>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</MatThemeProvider>
@code
{ MatTheme theme = new MatTheme()
{
Primary = MatThemeColors.Orange._500.Value,
Secondary = MatThemeColors.BlueGrey._500.Value
};
}
如果有效请告诉我。 :)
MatBlazor 文档说 "To apply theme for all application you can use MatThemeProvider in MainLayout.razor or App.razor"
该示例的信息量非常少。
将代码片段添加到 MainLayout.razor 或 App.razor 时不起作用。
我得到的错误是 "InvalidOperationException: The Router component requires a value for the parameter 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
};
}
你能试试这个吗?
<MatThemeProvider Theme="@theme">
<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>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</MatThemeProvider>
@code
{ MatTheme theme = new MatTheme()
{
Primary = MatThemeColors.Orange._500.Value,
Secondary = MatThemeColors.BlueGrey._500.Value
};
}
如果有效请告诉我。 :)