switch

Radio item.

Attribute NameTypeDefaultDescriptionMinimum Version
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)
  },
})