欢迎来到3672js教程,我们关注js教程、js框架、js代码特效等。

微信小程序(十六)form组件详细介绍,小程序form

3672Js.Com2019-03-10 03:09 来源:未知 阅读:15649 关注度3

微信小程序(十六)form组件详细介绍,小程序form


form表单组件 是提交form内的所有选中属性的值,注意每个form表单内的组件都必须有name属性指定否则提交不上去,button中的type两个submit,reset属性分别对应form的两个事件

主要属性:

wxml

<form bindsubmit="listenFormSubmit" bindreser="listenFormReser" >
 <checkbox-group name="checkbox" bindchange="listenerCheckbox">
  <label style="display: flex" wx:for-items="{{items}}">
   <checkbox value="{{item.name}}"/>{{item.value}}
  </label>
 </checkbox-group>

<!--button formType属性两个可选值submit, reset分别会触发form的submit,reser事件 -->
 <button formType="submit" type="primary">提交</button>
 <button formType="reset" type="warn">重置</button>
</form>

js

Page({
 /**
  * 初始化数据
  */
 data:{
 items: [
  {name: 'JAVA', value: 'Android', checked: 'true'},
  {name: 'Object-C', value: 'IOS'},
  {name: 'JSX', value: 'ReactNative'},
  {name: 'JS', value: 'wechat'},
  {name: 'Python', value: 'Web'}
 ]
 },

 listenCheckboxChange: function() {
 console.log(e.detail.value);
 },

 onLoad:function(options){
 // 页面初始化 options为页面跳转所带来的参数
 }
})

相关文章:

hello WeApp                      icon组件
Window                             text组件                                switch组件
tabBar底部导航                 progress组件                        action-sheet
应用生命周期                    button组件                            modal组件
页面生命周期                    checkbox组件                       toast组件
模块化详                           form组件详                            loading 组件
数据绑定                           input 组件                             navigator 组件
View组件                          picker组件                             audio 组件
scroll-view组件                 radio组件                              video组件
swiper组件                        slider组件                              Image组件

本站文章为3672js教程网友分享投稿,版权归原作者,欢迎任何形式的转载,但请务必注明出处。同时文章内容如有侵犯了您的权益,请联系我们处理。
评论已被关闭
{dede:include filename="foot.htm"/}