Home >WeChat Applet >Mini Program Development >Introduction to the form component of WeChat mini program

Introduction to the form component of WeChat mini program

不言
不言Original
2018-06-22 16:54:382083browse

This article mainly introduces relevant information about the detailed introduction of the form component of the WeChat applet. Friends who need it can refer to it

The form form component is all the components in the submitted form Select the value of the attribute. Note that each component in the form must have a name attribute specified, otherwise it will not be submitted. There are two submit and reset attributes in the button corresponding to the two events of the form.

Main attributes:

##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: &#39;JAVA&#39;, value: &#39;Android&#39;, checked: &#39;true&#39;},
  {name: &#39;Object-C&#39;, value: &#39;IOS&#39;},
  {name: &#39;JSX&#39;, value: &#39;ReactNative&#39;},
  {name: &#39;JS&#39;, value: &#39;wechat&#39;},
  {name: &#39;Python&#39;, value: &#39;Web&#39;}
 ]
 },

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

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

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to PHP Chinese net!

Related recommendations:

Implementation of cookie simulation by WeChat applet

## Snake game implemented by WeChat applet【 Source code attached】


The above is the detailed content of Introduction to the form component of WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn