开关(switch)
点击调用
---
```html
<view class="mt10 box flex">
<view class="flex1 form_title">
<text>{{ form.switchNotice.title }}</text>
</view>
<view class="flex0 form_content relative">
<view class="link" data-name="switchNotice" bindtap="formSwitchTap" data-change="switchChange"></view>
<view class="switch {{ form.switchNotice.value == 1 ? 'switch_on' : '' }}">
<view class="switch_ball {{ form.switchNotice.value == 1 ? 'switch_ball_on' : '' }}"></view>
</view>
</view>
</view>
```
```javascript
Page({
data: {
form: {
switchNotice: {
title: '消息通知',
required: true,
value: 1
}
}
},
// 开关切换状态后的回调
switchChange: function (type, value) {
let _this = this;
console.log(type + value)
}
});
```
配置项说明
---
|属性|类型|默认值|说明|
|-|-|-|-|
|bindtap|string|formPickShow|必需,不可更改|
|data-name|string|-|必需,组件实例名|
|data-change|string|-|可选,开关切换状态后的回调,有则调用,参数:name, value|