Applet - method to get input value

WeChat applet - method to get input value

1、 bindinput

wxml

<input name="text_name" type='text' bindinput='getValue' placeholder-style='font-size:28rpx;' placeholder='请输入信息'></input>

js

getValue(e){
  console.log(e.detail)   
}

insert image description here

Contains the value value, cursor is the position to get the cursor.

2、 bindsubmit

When there are too many forms to submit, it is more appropriate to choose bindsubmit. We distinguish wxml
from the input name field.

<form bindsubmit="formSubmit">
    <view class='name'>
        <text>名称:</text>
        <input name="eq" type='text' placeholder-style='font-size:28rpx;' placeholder='请输入名称'></input>
    </view>
    <view class='name'>
        <text>编码:</text>
        <input name="code" type='text' placeholder-style='font-size:28rpx;' placeholder='请输入编码'></input>
    </view>
    
    <button form-type='submit'>提交</button>
</form>

Get event js

formSubmit(e){
    // console.log(e)
    console.log(e.detail.value);
  },

Guess you like

Origin blog.csdn.net/TC_DESpipi/article/details/126316935