WeChat applet gets the value in the input box

I believe that many people will encounter many pits when they first enter the line of small programs. One of them is that they cannot obtain the content of the input input box. Today, I will talk about how to obtain this value.

There is a method on the applet input component called bindinput


Now let's take a look at the specific usage:

wxml:

<view class='regPhone'>
     <image src='../../images/reg-user.png' class='regCon-Icon'></image>
     <input type='text' value='' name='name' placeholder="请输入真实姓名" class='regCon-txt' placeholder-class='{{place}}' value='{{name}}' bindinput='formName' />
</view>

js:

  formName:function(e){
    this.setData({
      name:e.detail.value
    })
  },

In this way, you can get the value in this input.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325693264&siteId=291194637