diff --git a/package.json b/package.json index 2c99d69..c3e1f56 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "axios": "^0.20.0", "core-js": "^3.6.5", "vue": "^3.0.0-0", + "vue-axios": "^2.1.5", "vue-router": "^4.0.0-0", "vuex": "^4.0.0-0" }, diff --git a/src/config/axiosConfig.ts b/src/config/axiosConfig.ts new file mode 100644 index 0000000..69bc059 --- /dev/null +++ b/src/config/axiosConfig.ts @@ -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 \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index afeb174..a8fc2da 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,8 @@ import Antd from 'ant-design-vue'; import router from './router' import store from './store' 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') diff --git a/yarn.lock b/yarn.lock index 0b709d3..63e5464 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8726,6 +8726,11 @@ vm-browserify@^1.0.1: resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" 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: version "7.1.0" resolved "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.1.0.tgz#9cdbcc823e656b087507a1911732b867ac101e83"