微信小程序wx.request使用post方式传参
来源:互联网 发布:淘宝客服子取名字大全 编辑:程序博客网 时间:2024/05/13 07:06
需要注意的是method是get方式的时候,header为{"Content-Type": 'application/json'},当method为post时,header为{"Content-Type": "application/x-www-form-urlencoded"}
post方式传递的参数需要转换
1。js中
var util=require('../../utils/util.js');
page({
loginSubmit:function(e){
console.log(e.detail.value.username),
console.log(util.formatTime),
wx.request({
url: 'http://127.0.01:8000/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)
}
})
}
})
2. 在util中定义函数json2Form
function json2Form(json) {
var str = [];
for (var pin json) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p]));
}
return str.join("&");
}
module.exports.json2Form = json2Form
阅读全文
0 0
- 微信小程序wx.request使用post方式传参
- 微信小程序wx.request程序
- 小程序wx.request通过post方式提交数据给服务器-小程序支付开发教程
- 微信小程序 wx.request({})问题
- 微信小程序--wx.request使用psot传递数据
- 微信小程序学习wx.request 中 post 出现500错误的一些成因
- 微信小程序wx.request请求用POST后台得不到传递数据
- 微信小程序wx.request后台数据交互
- 微信小程序网络请求wx.request请求
- 微信小程序 wx.request()无返回结果
- 微信小程序 wx.request 的问题
- 微信小程序wx.request后台数据交互
- 微信小程序 wx.request wepy 简单封装
- 微信小程序-wx.request获取数据
- 微信小程序数据请求方法wx.request
- 微信小程序把玩(三十)wx.request(object) API
- 微信小程序的ajax数据请求wx.request
- 微信小程序 豆瓣项目中wx.request遇到的问题
- Java垃圾回收算法
- Zookeeper简单介绍
- 静态语言和动态语言
- 基于Dragonboard 410c的总线控制之I2C(三)
- PowerBI开发 第七篇:数据集和数据刷新
- 微信小程序wx.request使用post方式传参
- zabbix监控系统的详细使用
- sdnu1050水题1
- Maven讲解之 插件和目标
- js中怎样把ASCII码中的字符与十进制的数相互转换-学习笔记
- O2O分析报告
- shell programmable
- 汇编指令集
- spring 注解之@interface