获取输入框的内容 把这个值 给wx。request 中的 Data用 怎么写?
发布于 5 年前 作者 tding 4334 次浏览 来自 问答

大哥们 我想写个 输入框 然后获取输入框的内容 把这个值 给wx。request 中的 Data用 求大佬给个完整的代码 我太小白了 参数传递不过来

就是 这个 text 过不来

4 回复

X和Y 为参数名(自定义),后面对应的就是参数值

<input placeholder="请输入" bindinput="handleInput" />
data: {
 inputVal: ''
},
handleInput(e) {
  this.setData({
    inputVal: e.detail.value
  })
},
submitRequest() {
  wx.request({
    url: "https://api.xxx.com",
    method: "POST",
    data: {
      inputVal: this.data.inputVal
    },
    header: {
     "Content-Type": "application/json"
    },
    success: (res) => {
      console.log(res)
    }
  })
}
wx.request({
  url: "https:",
  method: "get",
   data: {
      "参数A": a,
      "参数B": b 
   },
  header: {
   "Content-Type": "application/json"
  },
  success: function(e){
  },
  fail: function(err){
  }
})
回到顶部