https://api.xdclass.net/pub/api/v1/web/index_card 测试接口
1、axios安装
2、axios全局配置在 main.ts中import vant from 'vant';import 'vant/lib/index.css';//引⼊vant样式组件//vant挂载到app这个实例上app.use(vant);npm install axios
3、发送⼀个axios请求验证⼀下
1、全局配置axiosimport axios from 'axios';//创建⼀个axios实例对象const http =axios.create( { //配置响应超时时常 // baseURL:'http://localhost:8080/api' });//设置请求拦截器http.interceptors.request.use((req)=>{ const token=window.sessionStorage.getItem('token'); return req;},(error)=>{ return error;})//设置响应拦截器http.interceptors.response.use((res)=>{ return res;},(error)=>{ return error;})//把http实例对象暴露出去export default http;
2、挂载到项⽬上import axios from './axios/axiosConfig';//将axios挂载到app这个实例上app.config.globalProperties.$http=axios;