switch

Switch.

Scan QR code to try:

switch

Property

TypeDescription
nameStringComponent name, used for form submission to get data.
checkedBooleanChecked or not.
disabledBooleanDisable or not.
colorStringComponent color.
onChangeEventHandleTrigger on checked change, event.detail={ value:checked}.
colorColorSwitch color.

Screenshot

switch

Sample Code

copy
<view class="page">
  <view class="switch-list">
    <view class="switch-item">
      <switch checked onChange="switchChange"/>
    </view>
  </view>
</view>
copy
Page({
  switchChange (e){
    console.log('switchChange event, value:', e.detail.value)
  },
})