axios的使用

xiaoxiao2021-02-28  58

1、引入

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

2、 注意Content类型:’Content-Type’: ‘application/x-www-form-urlencoded,application/json’, 如果post没有application/json,后台可能接收不到格式

axios({ method: 'post', url: 'KQ/mainControl', headers: { 'Content-Type': 'application/x-www-form-urlencoded,application/json', }, data: that.postdateSerchTemp, }) .then(function (req) { console.log(req); that.errMonthVal = req.data.data.message; that.reqMonSearchVal = req.data.data; }) .catch(function (err) { console.log(err); });

3、JSON格式

{'status':'kqadd','user':[{'id':'12'},{'id':'13'}]}
转载请注明原文地址: https://www.6miu.com/read-2621409.html

最新回复(0)