<Content>
<Field>
<Switch Checked="true" OnLabel="On" OffLabel="Off">
</Switch>
</Field>
<Field>
<Switch Color="Color.Success" Checked="true">
Switch - success
</Switch>
</Field>
<Field>
<Switch Color="Color.Warning" Checked="true">
Switch - warning
</Switch>
</Field>
<Field>
<Switch Color="Color.Danger" Checked="true">
Switch - danger
</Switch>
</Field>
<Field>
<Switch Color="Color.Info" Checked="true">
Switch - info
</Switch>
</Field>
<Notification Color="Color.Dark">
<Field>
<Switch Color="Color.White" Checked="true">
Switch - white
</Switch>
</Field>
</Notification>
</Content>
<Content>
<Field>
<Switch IsSmall Checked="true">
Switch - small
</Switch>
</Field>
<Field>
<Switch Checked="true">
Switch
</Switch>
</Field>
<Field>
<Switch IsMedium Checked="true">
Switch - medium
</Switch>
</Field>
<Field>
<Switch IsLarge Checked="true">
Switch - large
</Switch>
</Field>
</Content>
<Content>
<Field>
<Switch IsThin IsSmall Checked="true">
Switch - SmallThin
</Switch>
</Field>
<Field>
<Switch IsThin IsLarge Checked="true">
Switch - LargeThin
</Switch>
</Field>
<Field>
<Switch IsRounded Color="Color.Warning" Checked="true">
Switch - Rounded
</Switch>
</Field>
<Field>
<Switch IsOutlined Color="Color.Danger" Checked="true">
Switch - Outlined
</Switch>
</Field>
<Field>
<Switch disabled Color="Color.Success" Checked="true">
Switch - disabled
</Switch>
</Field>
<Field>
<Switch IsRTL Color="Color.Primary" Checked="true">
Switch - RTL
</Switch>
</Field>
</Content>
使用@bind-Checked, 绑定值必须是bool
<Content>
<Field>
<Label>Val的值:</Label>
<Control>
<Input Value="val" IsStatic />
</Control>
</Field>
<Field>
<Label>开关:</Label>
<Control>
<Switch @bind-Checked="val">
开关
</Switch>
</Control>
</Field>
<Field>
<Control>
<Button Color="Color.Info" @onclick="setNewValue">反选</Button>
</Control>
</Field>
</Content>
@code{
bool val;
void setNewValue()
{
val=!val;
}
}
文档