随笔分类 - axios
封装axios
摘要:// 封装axios import axios from "axios"; const http = axios.create({ baseURL: "http://localhost:3006/api", timeout: 5000 }) // 请求拦截 http.interceptors.req
跨域解决方案
摘要:目前主流的跨域解决方案有两种 1. 后台解决(cors) 2. 前台解决(proxy) // 在 vue.config.js 中添加配置 devServer: { proxy: { '/api': { target: '<url>', changeOrigin: true } } } // 跨域配置