May 18, 2021 WeChat Mini Program Development Document
Switch selector.
The property name | Type | The default | Description |
---|---|---|---|
checked | Boolean | false | Whether to select |
type | String | switch | Style, valid value: switch, checkbox |
bindchange | EventHandle | The change event is triggered when the checked changes, event.detail. | |
color | Color | Switch color, color with css |
<view class="body-view">
<switch checked bindchange="switch1Change"/>
<switch bindchange="switch2Change"/>
</view>
page({
switch1Checked: function (e){
console.log('switch1 发生 change 事件,携带值为', e.detail.value)
},
switch2Change: function (e){
console.log('switch2 发生 change 事件,携带值为', e.detail.value)
}
})