当前位置:   article > 正文

Bootstrap Blazor 实战 Dialog 对话框组件快速入门_bootstrap dialog 组件

bootstrap dialog 组件

官方文档

1. 注入服务 DialogService
@inject DialogService DialogService

或者后置代码

[Inject]
[NotNull]
private DialogService? DialogService { get; set; }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
2. 弹出说明
await DialogService.Show(new DialogOption()
{
    Title = "运行结果",
    IsScrolling = true,
    IsCentered = true,
    BodyTemplate = new RenderFragment(builder =>
    {
        builder.OpenElement(1, "p");
        builder.AddContent(2, "结果1结果2结果3结果4");
        builder.CloseElement();
    })
});
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

image

[特别介绍] SweetAlert 弹窗组件

SweetAlert

[Inject]
[NotNull]
private SwalService? SwalService { get; set; }

var op = new SwalOption()
{
    Title = Localizer["SwalOptionTitle"],
    Content = Localizer["SwalOptionContent"]
};
var ret = await SwalService.ShowModal(op);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

image

3. 弹出组件
DialogService.Show(new DialogOption()
{
    Title = "Built-in Counter component",
    Component = BootstrapDynamicComponent.CreateComponent<Counter>()
});
  • 1
  • 2
  • 3
  • 4
  • 5

image

4. 弹出编辑框
    string CurrentDirectory = "";
    void LoadFiles() { }
    public class NewFolders
    {

        [DisplayName("文件夹名称")]
        public string NewFolderName { get; set; }

    }


    private async Task ShowNewFolderDialog()
    {
        var newFolders = new NewFolders();
        var option = new EditDialogOption<NewFolders>()
        {
            Title = "新文件夹名称",
            Model = newFolders,

            OnEditAsync = context =>
            {
                string path = Path.Combine(CurrentDirectory, newFolders.NewFolderName);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    LoadFiles();
                }

                return Task.FromResult(true);
            }
        };

        await DialogService.ShowEditDialog(option);
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

image

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/80927
推荐阅读
相关标签
  

闽ICP备14008679号