axios 网络请求与数据下载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a5252145/article/details/84890469

axios

一、先引入js

第一种:通过cdn加载
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
第二种:通过npm或者cnpm加载
$ npm install axios

或者

$ cnpm install axios

二、请求与下载
请求第一种:

axios.get(url).then(function(response){
	console.log(response);
}).catch(function(error){
	console.log(error);
})
请求第一种:
//m,n表示url后面的参数,这是御用传参时使用,也就是url后面的参数放在外部执行
dict={
	m:a,
	n:b
}

axios.get(url,{params:dict}).then(function(response){
	console.log(response);
}).catch(function(error){
	console.log(error);
})

猜你喜欢

转载自blog.csdn.net/a5252145/article/details/84890469
今日推荐