How to get the value of the input tag in the applet

青灯夜游
Release: 2021-05-18 10:57:19
forward
4958 people have browsed it

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.

How to get the value of the input tag in the applet

Get the data in the input in the WeChat applet



登录


用户名

密码




Copy after login

Login js page

var app=getApp();
Page({
login:function(e){

  var url = app.globalData.serverIp +"/user/login.html?"
  +"username="+this.data.username
  +"&password="+this.data.password;
  
  var page=this;
  
  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;
  },
  })
},
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!