Skip to content

Commit 23a50fb

Browse files
committed
feat(Drawer): 增加 BodyContext 参数
1 parent 5960d5c commit 23a50fb

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/BootstrapBlazor/Components/Drawer/Drawer.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
}
1111
<div tabindex="-1" class="@DrawerClassString" style="@DrawerStyleString" @onclick:stopPropagation>
1212
<div class="drawer-content">
13-
<CascadingValue Value="Close" IsFixed=" true">
14-
@ChildContent
13+
<CascadingValue Name="BodyContext" Value="BodyContext" IsFixed="true">
14+
<CascadingValue Value="Close" IsFixed=" true">
15+
@ChildContent
16+
</CascadingValue>
1517
</CascadingValue>
1618
</div>
1719
@if (AllowResize)

src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ public partial class Drawer
113113
[Parameter]
114114
public Func<Task>? OnCloseAsync { get; set; }
115115

116+
/// <summary>
117+
/// 获得/设置 抽屉内容相关数据 多用于传值
118+
/// </summary>
119+
[Parameter]
120+
public object? BodyContext { get; set; }
121+
116122
/// <summary>
117123
/// <inheritdoc/>
118124
/// </summary>

src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ private Dictionary<string, object> GetParameters(DrawerOption option)
8888
{
8989
parameters.Add(nameof(Drawer.OnClickBackdrop), option.OnClickBackdrop);
9090
}
91+
if (option.BodyContext != null)
92+
{
93+
parameters.Add(nameof(Drawer.BodyContext), option.BodyContext);
94+
}
9195
return parameters;
9296
}
9397

src/BootstrapBlazor/Components/Drawer/DrawerOption.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ public class DrawerOption
6464
/// 获得/设置 关闭当前 Drawer 回调委托 默认 null
6565
/// </summary>
6666
public Func<Task>? OnCloseAsync { get; set; }
67+
68+
/// <summary>
69+
/// 获得/设置 相关连数据,多用于传值使用
70+
/// </summary>
71+
public object? BodyContext { get; set; }
6772
}

0 commit comments

Comments
 (0)