Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MainLayout.razor或App.razor中添加MatBlazor MatThemeProvider_Blazor_Matblazor - Fatal编程技术网

在MainLayout.razor或App.razor中添加MatBlazor MatThemeProvider

在MainLayout.razor或App.razor中添加MatBlazor MatThemeProvider,blazor,matblazor,Blazor,Matblazor,MatBlazor文档说“要为所有应用程序应用主题,您可以在MainLayout.razor或App.razor中使用MatThemeProvider” 这个例子的信息非常少 将代码段添加到MainLayout.razor或App.razor中时,它就是不起作用 我得到的错误是 “InvalidOperationException:路由器组件需要找到的参数值。” 如何为整个应用程序应用主题 App.razor <Router AppAssembly="@typeof(Program).As

MatBlazor文档说“要为所有应用程序应用主题,您可以在MainLayout.razor或App.razor中使用MatThemeProvider”

这个例子的信息非常少

将代码段添加到MainLayout.razor或App.razor中时,它就是不起作用

我得到的错误是 “InvalidOperationException:路由器组件需要找到的参数值。”

如何为整个应用程序应用主题

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
    };
}

正在确定会话状态,请稍候

对不起,这个地址什么也没有

@代码 { MatTheme主题=新MatTheme() { 主色=MatThemeColors.Orange.\u 500.Value, 二级=MatThemeColors.蓝灰色。_500.值 }; }
你能试试这个吗

<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
        }; 
    }

正在确定会话状态,请稍候

对不起,这个地址什么也没有

@代码 {MatTheme theme=新MatTheme() { 主色=MatThemeColors.Orange.\u 500.Value, 二级=MatThemeColors.蓝灰色。_500.值 }; }
请让我知道它是否有效。:)

你能试试这个吗

<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
        }; 
    }

正在确定会话状态,请稍候

对不起,这个地址什么也没有

@代码 {MatTheme theme=新MatTheme() { 主色=MatThemeColors.Orange.\u 500.Value, 二级=MatThemeColors.蓝灰色。_500.值 }; }

请让我知道它是否有效。:)

路由器组件
您确定这是关于matblazor的吗?请说明如何以及在何处添加
MatThemeProvider
,但似乎还有另一个问题请参阅更新的代码。如果我删除了,那么一切都正常。如果将它放在
主布局中,然后将其从您在问题中更新的代码中删除,会怎么样?同样的事情-不确定我怎么会弄错
路由器组件
您确定这是关于matblazor的吗?请说明如何以及在何处添加
MatThemeProvider
,但似乎还有另一个问题请参阅更新的代码。如果我删除了,那么一切都正常。如果将它放在
主布局中,然后将其从您在问题中更新的代码中删除,会怎么样?同样的事情-不确定我怎么会弄错!