search
HomeWeChat AppletMini Program DevelopmentDetailed introduction of WeChat mini program form component

Detailed introduction of WeChat mini program form component

The form component is to submit the values ​​​​of all selected attributes in the form. Note that each component in the form must have a name attribute specified, otherwise it will not be submitted. In the button The two submit and reset attributes of type respectively correspond to the two events of the form

Main attributes:

Detailed introduction of WeChat mini program form component

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为页面跳转所带来的参数
 }
})

For more detailed introduction to WeChat mini program form components and related articles, please pay attention to 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool