Welcome

首页 / 脚本样式 / JavaScript / 微信小程序(十六)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组件