通俗易懂的axios
2024-09-02 09:29:50
get的两种请求:
methods:{
//axios.get的发送参数有两种,两个ajax请求函数都可实现
sendGetByStr(){
//1.get通过直接发字符串拼接
axios.get(`get.php?name=${this.users.name}&age=${this.users.name}`)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
}); },
sendGetByObj(){
//2.get通过params选项
axios.get(`get.php?`,{
params:{
name:this.users.name,
age:this.users.age
}
})
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
}); }
}
})
post的一种
methods:{
sendPsot(){ axios.post('post.php', {
name: this.users.name,
age: this.users.age,
}) .then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
} }
最新文章
- SQL Server 2016 CTP2.2 安装手记
- C++高精度计时器——微秒级时间统计
- Linux下配置Node.js环境
- 2、python,for..in语句
- EUI ToggleButton ToggleSwitch 实现类似音乐开关按钮
- Android九宫格界面实现点击每个格点击跳转界面
- Sum of Left Leaves
- 转自:C#中TextBox水印提示的简单实现
- windows 2003 server 远程桌面禁用本地资源,磁盘驱动器,串行口,复制文件
- golang与C交互:cgo
- [书目20131223]Android、iPhone、Windows Phone手机网页及网站设计:最佳实践与设计精粹 - 张亚飞
- QQ群里收集的外企iOS开发的笔试题
- bzoj1029
- java多线程学习(两)——创建一个线程
- 教你一步搭建Flume分布式日志系统
- 【剑指offer】丑数
- WebStorm10 控制台中文乱码解决方案
- 初识MySQL数据库的各种CMD命令窗口下的指令
- Linux终端命令
- uva-10422-骑士-搜索题