微信小程序wx.request 使用 post方式传参

参考网址
https://blog.csdn.net/lengxin337/article/details/78234503

重点注意:

method 是  get  方式的时候,header为

{"Content-Type": 'application/json'},

method 为 post 时,header为

{"Content-Type": "application/x-www-form-urlencoded"}

wx:request

wx.request({
	url: 'http://...www/runxiang_yiyao/Mobile/Index/login',
	method: 'post',
	data: util.json2Form({
	username: e.detail.value.username,
	password: e.detail.value.password,
	}),
	
	header: {
	"Content-Type": "application/x-www-form-urlencoded"
	},
	success: function (res) {
		console.log(util.formatTime)
		// console.log(res)
	}
})

你可能感兴趣的:(小程序,小程序)