Vue2.x axios发送post请求
安装axios
$ npm install axios
//使用淘宝源
$ cnpm install axios
//或者使用cdn:一般不使用
script src=“https://unpkg.com/axios/dist/axios.min.js”
配置main.js
以下代码为之前开发的项目中的配置代码 可供参考
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Axios from 'axios'
import ElementUI from 'element-ui'
Axios.defaults.headers.post['Content-Type']='application/json'
Vue.config.productionTip = false
Vue.prototype.$axios=Axios
//请求拦截器
Axios.interceptors.request.use(function(config)