vue中:
// 使用post发送数据需要使用 var param=new URLSearchParams();修改传参方法
// 使用param.append("uname","xixi")添加数据并且使用data发送数据
var parm = new URLSearchParams();
param.append("username","cuicui")
axios({
url:"",
data:parm,
method:"post",
}).then((ok)=>
console.log(ok)
{})
react中:
需要qs第三方插件
import React, { Component } from 'react'
import Bar from '../components/bottombar.jsx'
import axios from 'axios'
import qs from 'qs'
export default class home extends Component {
componentDidMount(){
let data=qs.stringify({
uname:"哈哈哈",
upassword:"123"
})
axios({
url:"http://localhost:4399/ceshi/ceshi",
method:"post",
data
}).then((ok)=>{
console.log(ok);
}).catch((err)=>{
console.log(err);
})
}
render() {
return (
<div>
user
<Bar/>
</div>
)
}
}