Home  >  Article  >  WeChat Applet  >  WeChat applet-get user input content

WeChat applet-get user input content

高洛峰
高洛峰Original
2017-02-25 09:34:142446browse

In the WeChat applet, how to obtain the content input by the user? ?

js: document.getElementById("Content").value

jq: $("#Content").val()

cannot be written like this in the WeChat applet.

You can store the user input through the bindchange attribute of the component

test.wxml

<input id="postalCode" bindchange="bindChange" type="number" placeholder="输入邮政编码" auto-focus />
<input id="mail" bindchange="bindChange" type="number" placeholder="请输入邮箱地址" />

test.js

##

var inputContent = {}
Page({
 data: {
 inputContent: {}
 },
 bindChange: function(e) {
 inputContent[e.currentTarget.id] = e.detail.value
 }
})

Background output


WeChat applet-get user input content

For more WeChat applet-related articles on obtaining user input content, 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