标签 (Tag)

用于标记不同状态的数据。

概述

  • 支持默认、主要、成功、信息、警告、危险样式

代码演示

1.默认示例

测试
完成
通过
进行中
警告
失败
模板
namespace WebSite.Docus.View.Tags;

class Tag1 : BaseComponent
{
    protected override void BuildRenderTree(RenderTreeBuilder builder)
    {
        BuildTag(builder, StyleType.Default, "测试");
        BuildTag(builder, StyleType.Primary, "完成");
        BuildTag(builder, StyleType.Success, "通过");
        BuildTag(builder, StyleType.Info, "进行中");
        BuildTag(builder, StyleType.Warning, "警告");
        BuildTag(builder, StyleType.Danger, "失败");
        BuildTag(builder, StyleType.Success, b => b.IconName("fa fa-user", "模板"));
    }

    private static void BuildTag(RenderTreeBuilder builder, StyleType style, string text)
    {
        builder.Div("demo-tag", attr => builder.Tag(style, text));
    }

    private static void BuildTag(RenderTreeBuilder builder, StyleType style, Action<RenderTreeBuilder> content)
    {
        builder.Div("demo-tag", attr => builder.Tag(style, content));
    }
}