表单Form的应用很广泛,我们可以利用form设计登录注册,也可以设计一种答题问卷的形式,今天主要讲一下form的使用
form表单,将组件内输入的"switch","input","checkbox","slider","radio","picker"的值进行提交,数据的格式为:name:value,所以表单中控件都需要添加name属性,否则找不到对应控件的值。其主要属性:
主要代码,创建一个form表单:
- <!--pages/index/Component/FormM/FormM.wxml-->
- <view class="viewTitle">
- <text class="view-Name">form表单</text>
- <view class="lineView"></view>
- </view>
- <!--这里用form,name=“nameName1”可以作为form的属性进行
- (e.detail.value.nameName1)调用,
- form自带有提交和重置按钮,会自动获取表单中所有控件值的改变-->
- <form class="page__bd" 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 value="50" name="slider" show-value ></slider> <li o="" cl="" ptm="" pbm"="">