安装qs:cnpm install --save axios vue-axios qs
import qs from ‘qs’;
import axios from 'axios';
axios.post(url,qs.stringify({ // 通过qs.stringify()将对象解析成URL的形式
name:'0', age:'2'
}),{emulateJSON: true},{
headers:{"Content-Type": "application/x-www-form-urlencoded;charset=utf-8",}
}).then(reponse=>{
console.log(reponse)
this.tableData=reponse.data.data
})
ajax请求
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery</title>
</head>
<body>
<div>
<button class="post">post请求</button>
</div>
<script src="https://code.jquer