当前位置: 代码迷 >> 综合 >> 微信小程序开发(登陆获取输入框的值)
  详细解决方案

微信小程序开发(登陆获取输入框的值)

热度:83   发布时间:2024-02-06 17:00:36.0

UI框架用的是微赞

例子:

login.wxml

      <van-cell-group><van-fieldvalue="{{ ei_code }}"bind:change="getEi_code"clearableleft-icon="shop-o"placeholder="请输入商家编号"/><van-fieldvalue="{{ us_code }}"bind:change="getUs_code"          clearableleft-icon="user-o"placeholder="请输入用户编号"/><van-fieldvalue="{{ us_pwd }}"bind:change="getUs_pwd"type="password"left-icon="bag-o"placeholder="请输入密码"/></van-cell-group>

login.js

var that;
Page({data: {ei_code: '',us_code: '',us_pwd: ''},onLoad:function(){that = this;},openIndex(){wx.showToast({title: "商家编号:"+this.data.ei_code+" 用户编号:" +this.data.us_code+" 密码" +this.data.us_pwd,icon: 'none',duration: 2000})console.log("商家编号:"+this.data.ei_code+" 用户编号:" +this.data.us_code+" 密码" +this.data.us_pwd);},getEi_code(event) {that.setData({ei_code: event.detail});},getUs_code(event) {that.setData({us_code: event.detail});},getUs_pwd(event) {that.setData({us_pwd: event.detail});}})

注意事项:that和this的区别,在输入框上绑定事件(当内容改变时赋值)。

  相关解决方案