亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Dokumentasi pembangunan applet WeChat / 微信小程序表單組件 開關(guān) switch

微信小程序表單組件 開關(guān) switch

微信小程序switch

開關(guān)選擇器

QQ截圖20170208103226.png

<view class="section section_gap">
    <view class="section__title">type="switch"</view>
    <view class="body-view">
        <switch checked="{{switch1Checked}}" bindchange="switch1Change"/>
    </view>
</view>

<view class="section section_gap">
    <view class="section__title">type="checkbox"</view>
    <view class="body-view">
        <switch type="checkbox" checked="{{switch2Checked}}" bindchange="switch2Change"/>
    </view>
</view>
  data: {
    switch1Checked: true,
    switch2Checked: false,
    switch1Style: '',
    switch2Style: 'text-decoration: line-through'
  }
}
for(var i = 1; i <= 2; ++i) {
  (function(index) {
    pageData[`switch${index}Change`] = function(e) {
      console.log(`switch${index}發(fā)生change事件,攜帶值為`, e.detail.value)
      var obj = {}
      obj[`switch${index}Checked`] = e.detail.value
      this.setData(obj)
      obj = {}
      obj[`switch${index}Style`] = e.detail.value ? '' : 'text-decoration: line-through'
      this.setData(obj)
    }
  })(i)
}
Page(pageData)

201609231404446540.png