diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor b/src/BootstrapBlazor/Components/Layout/Layout.razor index 0dfb13c904952ed545175c9d978a1780da4f5203..1dc34ef9b21193506d82fbbe23eeb9824e702d59 100644 --- a/src/BootstrapBlazor/Components/Layout/Layout.razor +++ b/src/BootstrapBlazor/Components/Layout/Layout.razor @@ -58,6 +58,12 @@ { @NotAuthorized } + else if(IsErrorHandler) + { + + @Main + + } else { @Main @@ -107,6 +113,12 @@ RenderFragment RenderMain => } + else if(IsErrorHandler) + { + + @Main + + } else { @Main diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs index 4a509bf09a6730d27efd521f9aa6944aac970255..e4fb4bff3ec436aa29edbbf9ec0a3291a91b621a 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs @@ -669,13 +669,29 @@ namespace BootstrapBlazor.Components ? builder => { var index = 0; - builder.OpenComponent(index++); - if (Layout?.OnErrorHandleAsync != null) + if (ErrorLogger != null) { - builder.AddAttribute(index++, nameof(BootstrapBlazor.Components.ErrorLogger.OnErrorHandleAsync), Layout.OnErrorHandleAsync); + // 未使用 Layout 组件 + builder.OpenComponent>(index++); + builder.AddAttribute(index++, nameof(CascadingValue.Value), ErrorLogger); + builder.AddAttribute(index++, nameof(CascadingValue.IsFixed), true); + builder.AddAttribute(index++, nameof(CascadingValue.ChildContent), content); + builder.CloseComponent(); + } + else + { + // 使用 Layout 组件 + if (Layout != null && Layout.IsErrorHandler) + { + builder.OpenComponent(index++); + if (Layout.OnErrorHandleAsync != null) + { + builder.AddAttribute(index++, nameof(Components.ErrorLogger.OnErrorHandleAsync), Layout.OnErrorHandleAsync); + } + builder.AddAttribute(index++, nameof(Components.ErrorLogger.ChildContent), content); + builder.CloseComponent(); + } } - builder.AddAttribute(index++, nameof(BootstrapBlazor.Components.ErrorLogger.ChildContent), content); - builder.CloseComponent(); } : content; }