说明
Kind 决定语义配色,Size 决定尺寸,Loading 会自动禁用并显示加载指示。
常见能力:
- primary / outline / soft / text 等语义
- sm / md / lg 尺寸
- Loading 与 IconOnly
- Block 块级
用法
<Button Kind="primary" Icon="plus" Text="新建" OnClick="@(() => { })" />
<Button Kind="outline" Loading="true" Text="提交中" />
API 参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
Action |
string |
null |
按钮的动作码:与页面处理方法上的 [Action("add","新增")] 对齐。设置后本按钮受按钮级授权约束—— 当前用户在所属模块下没被勾中该动作时整个不渲染(禁用等于向无权者宣告「这里有个功能」)。留空则不受约束, 普通按钮、以及未接入权限体系的宿主行为完全不变。 |
Block |
bool |
false |
块级按钮(占满整行)。 |
ChildContent |
RenderFragment |
null |
|
Circle |
bool |
false |
圆形按钮。 |
Icon |
string |
null |
图标名,参见 IconData;位置由 IconPosition 决定。 |
IconOnly |
bool |
false |
仅图标按钮(等宽)。 |
IconPosition |
string |
"start" |
图标位置:start(默认,文字前)/ end(文字后,如下拉箭头)。 |
Kind |
string |
null |
视觉风格:primary / default / outline / soft / text / link / danger / danger-soft / success / success-soft / warning / warning-soft / info / info-soft。 留空则为无背景样式。 |
Loading |
bool |
false |
加载中,同时禁用。 |
NativeType |
string |
"button" |
原生 button 类型:button / submit / reset。 |
OnClick |
EventCallback<MouseEventArgs> |
— | 事件 |
Size |
string |
null |
尺寸:lg / sm / xs。 |
Text |
string |
null |
按钮文字。 |
Title |
string |
null |
悬浮提示,等价于 title。 |
Visible |
bool |
true |
取得或设置组件是否可见,默认为false。 |
VisibleChanged |
EventCallback<bool> |
— | 事件 取得或设置组件可见性变化时的回调事件。 |
Class |
string |
null |
取得或设置组件的CSS类名,用于自定义样式。 |
Disabled |
bool |
false |
取得或设置组件是否禁用,默认为false。 |
Style |
string |
null |
取得或设置组件的内联样式,用于自定义样式。 |
所有组件均继承
BaseComponent,除上表参数外还支持Class、Style、Disabled、Visible。
扫码关注公众号
扫码加入 QQ 群