Background there is a problem in the introduction of Axios
code
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './reset.css'
Vue.config.productionTip = false
Vue.use(ElementUI);
axios.default.baseURL = 'https://www.fastmock.site/mock/ad1bc58516abb5f0f452402035be2443/houtai'
Vue.prototype.$http = axios
This is because the order of the two lines of code is wrong
change to
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './reset.css'
axios.default.baseURL = 'https://www.fastmock.site/mock/ad1bc58516abb5f0f452402035be2443/houtai'
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.use(ElementUI);
Read More:
- [Solved] vite2+vue3 jsx Error: React is not defined
- [Solved] Vue item error: Regeneratorruntime is not defined
- Ant design vue table Error: h is not defined [How to Solve]
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- vue eslint error ‘process‘ is not defined no-undef [How to Solve]
- [Solved] Uncaught ReferenceError: axios is not defined
- [Solved] Vue3 process Error: Uncaught ReferenceError: process is not defined
- How to Solve Vue add element Install Error
- Vue: How to Solve error avoided redundant navigation to current location: “/xxx”
- [Solved] Vuepress Package Error: document is not defined
- Vue2.0: How to Use vue3 api to encapsulate Axios
- How to Solve Vue route jump repeated clicks Error
- [Solved] Vue Error: error: ‘to‘ is defined but never used (no-unused-vars)
- How to Solve Vue loading 3D model Error
- [Solved] Vue Error: template or render function not defined
- vue error: ‘ev’ is defined but never used (no-unused-vars)
- Vue: How to Solve Eslint error
- ERROR in [eslint] ESLint is not a constructor (How to Solve)
- How to Solve OffsetParent is not set error
- How to Solve Vue3 jweixin-module Error