コード例 #1
0
 /// <summary>
 /// 将配置信息转化为参数集合
 /// </summary>
 /// <param name="option"></param>
 /// <returns></returns>
 internal static IDictionary <string, object?> Parse(SwalOption option) => new Dictionary <string, object?>()
 {
     [nameof(SweetAlertBody.Category)]       = option.Category,
     [nameof(SweetAlertBody.ShowClose)]      = option.ShowClose,
     [nameof(SweetAlertBody.IsConfirm)]      = option.IsModalConfirm,
     [nameof(SweetAlertBody.ShowFooter)]     = option.ShowFooter,
     [nameof(SweetAlertBody.OnClose)]        = new Action(async() => await option.Close(false)),
     [nameof(SweetAlertBody.OnConfirm)]      = new Action(async() => await option.Close(true)),
     [nameof(SweetAlertBody.Title)]          = option.Title,
     [nameof(SweetAlertBody.Content)]        = option.Content,
     [nameof(SweetAlertBody.BodyTemplate)]   = option.BodyTemplate,
     [nameof(SweetAlertBody.FooterTemplate)] = option.FooterTemplate,
     [nameof(SweetAlertBody.ButtonTemplate)] = option.ButtonTemplate
 };
コード例 #2
0
        private Task ShowButtons()
        {
            var op = new SwalOption()
            {
                Category  = SwalCategory.Success,
                Title     = "我是 Title",
                Content   = "我是 Content",
                ShowClose = false
            };

            op.ButtonTemplate = new RenderFragment(builder =>
            {
                builder.OpenComponent <Button>(0);
                builder.AddAttribute(1, nameof(Button.Text), "自定义关闭按钮");
                builder.AddAttribute(2, nameof(Button.OnClick), EventCallback.Factory.Create <MouseEventArgs>(this, async() => await op.Close()));
                builder.CloseComponent();
            });
            SwalService.Show(op);
            return(Task.CompletedTask);
        }