Switch
Introduction
Switch is used to toggle options on or off.
Property Description
| Field | Description | Type | Default |
|---|---|---|---|
| active | The state of the switch. | Boolean | FALSE |
| size | The size of the switch. Options: small/base/large | String | base |
| disabled | Whether the switch is disabled. | Boolean | FALSE |
| label | Inline text label, separated by a vertical line. e.g. ON / OFF | String |
Events
| Name | Description | Callback Parameters |
|---|---|---|
| change | Triggered when toggled | value |
Example
<view class="bg-white br4 pd16">
<mswitch size="large" :active="false" bind:change="handleSwitch"></mswitch>
</view>
Page({
data: {},
handleSwitch(val) {
console.log('switch====', val);
},
});