http://www.axios-js.com/zh-cn/docs/
get传值 -- 放在params里面post传值 -- 放在data里面
Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中。
9-1 安装
// 使用 npm$ npm install axios// 使用 bower$ bower install axios// 使用 cdn<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
9-2 get
axios.get(url).then(res=>{console.log(res);})
// var url = "http://192.168.4.18:3000/search?keywords=你"axios.get("http://192.168.4.18:3000/search",{params:{keywords:"你"}}).then(res=>{console.log(res);})
9-3 axios
axios({url,baseURL,method,params:{} //问号后面的值}).then(res=>{console.log(res)})
axios({url:"/search",baseURL:"http://192.168.4.18:3000",method:"get",params:{keywords:"你"}}).then(res=>{console.log(res);})
9-4 axios二次封装
var baseURL="http://192.168.4.18:3000/"function http({url,method:"get",params:{}}){return axios({url,baseURL,method,params})}
http({url:"/album?id=96964667",}).then(res=>{console.log(res)})http({url:"/album",params:{id:"96964667"}}).then(res=>{console.log(res)})
