添加axios 添加全局配置
This commit is contained in:
parent
4f571bfc47
commit
4fbf1353da
@ -12,6 +12,7 @@
|
|||||||
"axios": "^0.20.0",
|
"axios": "^0.20.0",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"vue": "^3.0.0-0",
|
"vue": "^3.0.0-0",
|
||||||
|
"vue-axios": "^2.1.5",
|
||||||
"vue-router": "^4.0.0-0",
|
"vue-router": "^4.0.0-0",
|
||||||
"vuex": "^4.0.0-0"
|
"vuex": "^4.0.0-0"
|
||||||
},
|
},
|
||||||
|
8
src/config/axiosConfig.ts
Normal file
8
src/config/axiosConfig.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
axios.defaults.baseURL = 'https://api.example.com';
|
||||||
|
axios.defaults.headers.common['Authorization'] = 'token';
|
||||||
|
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default axios
|
@ -4,6 +4,8 @@ import Antd from 'ant-design-vue';
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import 'ant-design-vue/dist/antd.css';
|
import 'ant-design-vue/dist/antd.css';
|
||||||
|
import axios from "./config/axiosConfig"
|
||||||
|
import VueAxios from "vue-axios"
|
||||||
|
|
||||||
|
|
||||||
createApp(App).use(store).use(router).use(Antd).mount('#app')
|
createApp(App).use(store).use(router).use(Antd).use(VueAxios,axios).mount('#app')
|
||||||
|
@ -8726,6 +8726,11 @@ vm-browserify@^1.0.1:
|
|||||||
resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
|
resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
|
||||||
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
|
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
|
||||||
|
|
||||||
|
vue-axios@^2.1.5:
|
||||||
|
version "2.1.5"
|
||||||
|
resolved "https://registry.npm.taobao.org/vue-axios/download/vue-axios-2.1.5.tgz#1af4bf1218ed71309c76afb38d0f683e312c24a7"
|
||||||
|
integrity sha1-GvS/EhjtcTCcdq+zjQ9oPjEsJKc=
|
||||||
|
|
||||||
vue-eslint-parser@^7.0.0, vue-eslint-parser@^7.1.0:
|
vue-eslint-parser@^7.0.0, vue-eslint-parser@^7.1.0:
|
||||||
version "7.1.0"
|
version "7.1.0"
|
||||||
resolved "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.1.0.tgz#9cdbcc823e656b087507a1911732b867ac101e83"
|
resolved "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.1.0.tgz#9cdbcc823e656b087507a1911732b867ac101e83"
|
||||||
|
Loading…
Reference in New Issue
Block a user