This article will introduce you to the method of WeChat applet to obtain the input tag value. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Get the data in the input in the WeChat applet
<scroll-view> <view id='titleView'> <text id="titleText">登录</text> </view> <view id='mainView'> <text>用户名</text> <input class='input' bindinput='usernameInput'></input> <text>密码</text> <input class='input' bindinput='passwordInput'></input> <button class="btn" bindtap='login'>登录</button> <button class='btn' bindtap='toRegister'>注册</button> </view> </scroll-view>
Login js page
var app=getApp(); Page({ login:function(e){ <!--拼接url通过后台验证跳转 this.data.username获取标签中值--> var url = app.globalData.serverIp +"/user/login.html?" +"username="+this.data.username +"&password="+this.data.password; <!--为this赋值给全局对方法中调用--> var page=this; <!--用request进行后台传输--> wx.request({ url: url, success:function(response){ var serverData=response.data; var status=serverData.status; var msg="登录失败"; if(status==200){ msg="登录成功"; //跳转商场首页navigateTo wx.navigateTo({ url:"../storeindex/storeindex", }) //把username保存到手机上 //sync表示同步 setStorageSync函数的作用是同步保存数据相当于http中的cookie wx.setStorageSync("username", page.data.username); } wx.showToast({ title: msg }) }, fail:function(e){ console.log("联网失败"); console.log(e); }, data: { username:"", password:"" }, usernameInput:function(e){ this.data.username=e.detail.value; }, passwordInput: function (e) { this.data.password = e.detail.value; }, }) },
Related learning recommendations: 小Program development tutorial
The above is the detailed content of How to get the value of the input tag in the applet. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools
