File tree Expand file tree Collapse file tree 5 files changed +32
-1
lines changed
BootstrapBlazor.Server/Components
BootstrapBlazor/Components/Mask Expand file tree Collapse file tree 5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1+ <div style =" background-color : #ffffff " class =" row" >
2+ <div class =" col-12" >
3+ <h3 >MaskDemo</h3 >
4+ </div >
5+ <div class =" col-12" >
6+ <Button Text =" Close" OnClick =" () => { OnCloseAsync?.Invoke(); }" ></Button >
7+ </div >
8+ </div >
9+ @code {
10+ [CascadingParameter ]
11+ private Func <Task >? OnCloseAsync { get ; set ; }
12+ }
Original file line number Diff line number Diff line change 2727 <Mask @ref =" CustomMask1" ></Mask >
2828 <Mask @ref =" CustomMask2" ></Mask >
2929</DemoBlock >
30+
31+ <DemoBlock Title =" 代码关闭弹窗" >
32+ <Button Text =" Show" OnClick =" ShowCloseMask" ></Button >
33+ </DemoBlock >
Original file line number Diff line number Diff line change @@ -56,4 +56,12 @@ await MaskService.Show(new MaskOption()
5656 await MaskService . Close ( CustomMask1 ) ;
5757 await MaskService . Close ( CustomMask2 ) ;
5858 }
59+
60+ private async Task ShowCloseMask ( )
61+ {
62+ await MaskService . Show ( new MaskOption ( )
63+ {
64+ ChildContent = BootstrapDynamicComponent . CreateComponent < MaskDemo > ( ) . Render ( )
65+ } ) ;
66+ }
5967}
Original file line number Diff line number Diff line change 99 @if (_options is { ChildContent : not null })
1010 {
1111 <div class =" bb-mask-content" >
12- @_options.ChildContent
12+ <CascadingValue Value =" CloseAsync" IsFixed =" true" >
13+ @_options.ChildContent
14+ </CascadingValue >
1315 </div >
1416 }
1517 </div >
Original file line number Diff line number Diff line change @@ -58,4 +58,9 @@ private Task Show(MaskOption? option)
5858 StateHasChanged ( ) ;
5959 return Task . CompletedTask ;
6060 }
61+
62+ private Task CloseAsync ( )
63+ {
64+ return Show ( null ) ;
65+ }
6166}
You can’t perform that action at this time.
0 commit comments