为何tourl:tourl,这句直接换成url:'http://localhost/app/',就可以。一换成接收变量就不行?我 console.log('tourl',tourl)都可以打印出变量
var util = require('../../utils/util.js')
util.httpget({
tourl:baseURL+'1.asp',
});
const httpget = function(tourl){
// load提示框,可以自定义
console.log('tourl',tourl)
wx.showLoading({
title: "加载中...",
mask: true,
});
wx.request({
url:tourl,
data: {
id1: 6,
id2: 'addoil',
id3:'16665',
},
method: 'POST', //接收请求的方式,如果不传默认为POST
header: {
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
},
success: (res) => {
wx.hideLoading(); // 隐藏load框
console.log('回调',res) // 将请求结果resolve出去
}
})
}
this.baseURL = 'http://example.com'; // 需要替换为实际的 URL
url: this.baseURL + tourl, // 将 baseURL 加入到 URL 中
改成这样的试试