ajax函数库axios基本使用

ajax函数库Axios基本使用

简介:Axios 对原生的Ajax进行了封装,简化书写,快速开发。
官网:https://www.axios-http.cn/

Axios使用步骤

  1. 引入Axios的js文件(参考官网)
  2. 使用Axios发送请求,获取相应结果
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

axios({
	method:'GET',
	url:'https://***********'
}).then((result)=>{
	console.log(result.data);
}).catch((err)=>{
	alert(err);
});

Axios-请求方式别名(推荐)

为了方便起见,Axios已经为所有支持的请求方法提供了别名
格式:axios.请求方式(url [, data [, config]])

axios.get('http://************').then((result)+>{
	console.log(result.data);
}).catch((err)=>{
	console.log(err);
});

axios.post('http://************',data).then((result)+>{
	console.log(result.data);
}).catch((err)=>{
	console.log(err);
});

相关推荐

  1. ajax函数axios基本使用

    2024-02-14 05:32:02       56 阅读
  2. axios(ajax请求)

    2024-02-14 05:32:02       23 阅读
  3. 01.AJAX 概念和 axios 使用

    2024-02-14 05:32:02       40 阅读
  4. Ajax&Axios

    2024-02-14 05:32:02       36 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-14 05:32:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-14 05:32:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-14 05:32:02       82 阅读
  4. Python语言-面向对象

    2024-02-14 05:32:02       91 阅读

热门阅读

  1. SpringBoot 动态加载jar包,动态配置

    2024-02-14 05:32:02       53 阅读
  2. PyTorch detach():深入解析与实战应用

    2024-02-14 05:32:02       71 阅读
  3. Sketch 99.1 for macOS

    2024-02-14 05:32:02       48 阅读
  4. 如何在自己笔记本电脑上模拟串口通讯

    2024-02-14 05:32:02       50 阅读