Technology Sharing

WeChat Mini Program Development Notes: "Form cannot read data" Solution Guide

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

WeChat Mini Program Development Notes: "Form cannot read data" Solution Guide

1. Problem Description

I havewxmlCode:

<view class="formclass">
  <form bindreset="formReset" bindsubmit="getformdata">
    <view class="ctl">
      <view class="cfg-area">
        <view>配置名</view>
        <input class="inputctl"  placeholder="配置1" value="重置测试"/>
      </view>
      <view class="button-area">
        <button class="formclassbutton1" form-type="submit" >提交</button>
        <button class="formclassbutton2" form-type="reset">重置</button>
      </view>
    </view>
  </form>
</view>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

I havejsForm processing function:

getformdata: function(e){
    console.log(e.detail.value);
  }
  • 1
  • 2
  • 3

The dictionary printed after submission is empty and it was stuck for more than ten minutes.

2. Problem Solving

After I got better, I forgot that form controls must be addednameThe data can be submitted only if the attribute is set, otherwise it is invalid. The following is the corrected key code:

<input class="inputctl" name="configName" placeholder="配置1" value="重置测试"/>
  • 1