首页 > 编程知识 正文

elementui上传封装axios,axios接口封装

时间:2023-05-05 14:17:35 阅读:274274 作者:1721

// The Vue build version to load with the `import` command// (runtime-only or standalone) has been set in webpack.base.conf with an alias.import Vue from 'vue'import ElementUI from 'element-ui';import 'element-ui/lib/theme-chalk/index.css';import App from './App'import router from './router'import './assets/css/style.css'import axios from "axios"Vue.config.productionTip = falseVue.use(ElementUI);// 指定baseurl 都会跟这个地址let axios_obj = axios.create({ baseUrl:'http://localhost/api/v1/'})// 请求拦截器axios_obj.interceptors.request.use(function(conf){ // console.log(conf) if(conf.url != 'login'){ conf.headers.token = 'haha' } return conf // Vue.prototype.$axios = conf})Vue.prototype.$axios = axios_obj// Vue.prototype.$axios = axios/* eslint-disable no-new */new Vue({ el: '#app', router, components: { App }, template: '<App/>'})

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。