随笔分类 - 前端 / axios
摘要:新建network文件夹及request.js import axios from 'axios' export function request(config){ //创建axios实例 const instance = axios.create({ baseURL: 'http://123.20
阅读全文
摘要:axios提供了两大类拦截器 一种是请求方向的拦截器(成功请求 失败请求)另一种是响应方向的(成功的 失败的) 作用:用于在网络请求的时候在发起请求或者响应时,对操作进行处理。①发起请求时可以添加网页加载的动画。②使用token认证时可以判断用户有无登录(强制登录) 请求拦截器 <script> a
阅读全文
摘要:<script> let newVar=axios.create({ baseURL:'http://localhost:8080/student', timeout:5000 });//创建axios实例 let newVar1=axios.create({ baseURL:'http://loc
阅读全文
摘要:<script> axios.defaults.baseURL='http://localhost:8080/student';//配置全局属性 axios.defaults.timeout=10000;//超时10s axios.get('getAllstudent').then(res=>{//
阅读全文
摘要:方式一 <script> axios([ axios.get('http://localhost:8080/student/getAllStudent'), axios.post('http://localhost:8080/student/getStudentById',{id:1}) ]).th
阅读全文
摘要:使用axios.get方式发送无参请求 <script> axios.get('http://localhost:8080/student/getAllStudent').then(res=>{ console.log(res.data); }).catch(err=>{ console.log(e
阅读全文
摘要://使用默认方式发送无参请求 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <
阅读全文