0
点赞
收藏
分享

微信扫一扫

小程序提交数据到后台做加法运算

流计算Alink 2022-08-02 阅读 35


源代码:

// pages/add/add.js
let a=0;
let b=0;

Page({
data:{
result:""
},
//获取a
GetA(e){
a=e.detail.value
},

//获取b
GetB(e){
b = e.detail.value
},

//提交并做计算
add(){
console.log(a,b)
let that=this
wx.request({
url: 'http://localhost:8080/demo4',
method:'post',
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
data:{
a:a,
b:b
},
success(res){
console.log("计算成功",res)
that.setData({
result:res.data
})
},fail(res){
console.log("计算失败",res)
}
})
}
})


举报

相关推荐

0 条评论