12345678910111213141516171819202122 |
- /* eslint-disable no-console */
- /* eslint-disable no-param-reassign */
- import Vue from 'vue';
- import AxiosWrapper from '../utils/axios-wrapper';
- const Plugin = {
- install(vue, options) {
- // 3. 注入组件
- vue.mixin({
- created() {
- if (this.$store && !this.$store.$axios) {
- this.$store.$axios = this.$axios;
- }
- },
- });
- // 4. 添加实例方法
- vue.prototype.$axios = new AxiosWrapper(options);
- },
- };
- Vue.use(Plugin, { baseUrl: process.env.VUE_APP_AXIOS_BASE_URL, unwrap: true });
|