axios 默认是 Payload 格式数据请求,但有时候后端接收参数要求必须是 Form Data 格式的,所以我们就得进行转换.Payload 和 Form Data 的主要设置是根据请求头的 Content-Type 的值来的. Payload Content-Type: 'application/json; charset=utf-8' Form Data Content-Type: 'application/x-www-form-urlencoded' 一.设置单个
什么是axios axios is a promise based HTTP client for the browser and node.js Features: Make XMLHttpRequests from the browser Make http requests from node.js Supports the Promise API Intercept request and response Transform request and response data Canc
1.在src下新建util文件夹,在util下新建request.js文件: 封装axios: import axios from 'axios' import QS from 'qs'; // import store from '@/store/index.js'; import { Message } from 'element-ui'; //element库的消息提示,可以不用 // 环境的切换 // if (process.env.NODE_ENV == 'development')