怎么用wx.request发送data里的变量
发布于 5 年前 作者 fang97 690 次浏览 来自 问答

通过输入框写了数据到data的fitV里面,怎么在request里面发送  fitValue 变量呢?  后台能收到username,但是加上fitValue小程序就会报错

求大神指导怎么修改

thirdScriptError

fitValue is not defined; [Component] Event Handler Error @ pages/begin/begin#bound bindtest

ReferenceError: fitValue is not defined

data: {

fitValue: ‘’,

fitV:’’,

},

bindtest: function() {

wx.request({

url: http://localhost:8080/JianShen/fitness,

data: {

fitword: fitValue,(不知道怎么写)

username: ‘001’,

password: ‘abc’

},

method: ‘GET’,

header: {

‘content-type’: ‘application/json’ // 默认值

},

success: function(res) {

console.log(res.data);

},

fail: function(res) {

console.log("…fail…");

}

})

},

// 输入框

inputChange: function(e) {

this.setData({

fitValue: e.detail.value

})

1 回复

bindtest: function() {

let that = this;

wx.request({

url: 'http://localhost:8080/JianShen/fitness',

data: {

fitword: that.data.fitValue,(这么写)

username: '001',

password: 'abc'

},

回到顶部