diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor index dafd97533d7511394f59280b2f3635c2e370ec63..d7055341bb51a36f80105a44e280cae747c71fdb 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor @@ -4,6 +4,27 @@
Show 方法弹出窗口进行人机交互组件使用介绍:
+ +1. 注入服务 DialogService
@@inject DialogService DialogService+
[Inject]
+[NotNull]
+private DialogService? DialogService { get; set; }
+
+2. 调用其实例 api
var op = new DialogOption()
+{
+ Title = "数据查询窗口",
+ ShowFooter = false,
+ BodyContext = DataPrimaryId
+};
+op.Component = BootstrapDynamicComponent.CreateComponent<DataDialogComponent>(new Dictionary<string, object?>
+{
+ [nameof(DataDialogComponent.OnClose)] = new Action(async () => await op.Dialog.Close())
+});
+await DialogService.Show(op);
+
通过设置 DialogOption IsKeyboard 参数,开启弹窗是否支持 ESC,请点击后面按钮设置后再点击 弹窗 按钮测试效果
组件使用介绍:
+ +1. 注入服务 MessageService
@@inject MessageService MessageService+
[Inject]
+[NotNull]
+private MessageService? MessageService { get; set; }
+
+2. 调用其实例 api
await MessageService.Show(new MessageOption()
+{
+ Content = "这是一条提示消息"
+});
+
组件使用介绍:
+ +1. 注入服务 SwalService
@@inject SwalService SwalService+
[Inject]
+[NotNull]
+private SwalService? SwalService { get; set; }
+
+2. 调用其实例 api
var op = new SwalOption()
+{
+ Category = SwalCategory.Success,
+ Title = "我是 Title",
+ Content = "我是 Content",
+ ShowClose = false
+};
+await SwalService.Show(op);
+
组件使用介绍:
+ +1. 注入服务 ToastService
@@inject ToastService ToastService+
[Inject]
+[NotNull]
+private ToastService? ToastService { get; set; }
+
+2. 调用其实例 api
await ToastService.Success("Title", "Content", autoHide: true);
+
- 需要在使用本组件的页面中内置 Toast 组件,或者在 MainLayout 主布局组件中内置,示例代码如下:
-
<Toast />-
BootstrapBlazorOptions 全局统一配置参数可以设置整个系统内的 Toast 组件 Delay 参数值通过配置文件 appsetting.json 文件配置,适用于 Server-Side App