1引入cdn环境使用axios
第一步引入cdn地址
1>指定版本{下载地址---https://www.bootcdn.cn/axios/}
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
2>同步最新版本{不建议使用}
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
第二步
1>get请求方式
axios.get('请求地址', {
params: {
"参数名": "传递的参数"
}
})
.then(function (res) {
console.log("返回结果==>",res);
})
.catch(function (error) {
console.log(error);
});
2>post请求方式
axios.post('请求地址', {
"参数名": "传递的参数",
"参数名": "传递的参数"'
})
.then(function (response) {
console.log("返回结果==>",res);
})
.catch(function (error) {
console.log(error);
});