码迷,mamicode.com
首页 > 微信 > 详细

微信小程序组件form

时间:2016-10-17 14:03:54      阅读:417      评论:0      收藏:0      [点我收藏+]

标签:

表单组件form:官方文档

 

Demo Code:

技术分享
Page({
  formSubmit: function(e) {
    console.log(‘form发生了submit事件,携带数据为:‘, e.detail.value)
  },
  formReset: function() {
    console.log(‘form发生了reset事件‘)
  }
})
JS
技术分享
<form bindsubmit="formSubmit" bindreset="formReset">
  <view class="section section_gap">
    <view class="section__title">switch</view>
    <switch name="switch"/>
  </view>
  <view class="section section_gap">
    <view class="section__title">slider</view>
    <slider name="slider" show-value ></slider>
  </view>

  <view class="section">
    <view class="section__title">input</view>
    <input name="input" placeholder="please input here" />
  </view>
  <view class="section section_gap">
    <view class="section__title">radio</view>
    <radio-group name="radio-group">
      <label class="checkbox"><radio value="radio1"/>radio1</label>
      <label class="checkbox"><radio value="radio2"/>radio2</label>
    </radio-group>
  </view>
  <view class="section section_gap">
    <view class="section__title">checkbox</view>
    <checkbox-group name="checkbox">
      <label class="checkbox"><checkbox value="checkbox1"/>checkbox1</label>
      <label class="checkbox"><checkbox value="checkbox2"/>checkbox2</label>
    </checkbox-group>
  </view>
  <view class="btn-area">
    <button formType="submit">Submit</button>
    <button formType="reset">Reset</button>
  </view>
</form>
WXML
技术分享
.section__title{
    font-family:‘Segoe UI‘, Tahoma, Geneva, Verdana, sans-serif;
    padding:5px;
}
label{
    font-family:‘Segoe UI‘, Tahoma, Geneva, Verdana, sans-serif;
}
.section_gap{
    margin-top: 10px;
}
.checkbox{
    display:block;
    margin-left:10px;
    margin-top:5px;
}
WXSS

 

微信小程序组件form

标签:

原文地址:http://www.cnblogs.com/betterlife/p/5969060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!