在main.js中
import axios from 'axios'
Vue.prototype.$axios= axios; // axios 改写为 Vue 的原型属性
在页面中直接使用
this.$axios.get('url地址', {
}).then(response => {console.log(response)}).catch((error) => {alert('请求失败了哦')})
在main.js中
import axios from 'axios'
Vue.prototype.$axios= axios; // axios 改写为 Vue 的原型属性
在页面中直接使用
this.$axios.get('url地址', {
}).then(response => {console.log(response)}).catch((error) => {alert('请求失败了哦')})