说明: axios封装 vue路由 tp路由 去掉index.php头,建议先下载源码再看。
安装axios:
使用 npm:
$ npm install axios |
使用 bower:
$ bower install axios |
引用:
import Vue from 'vue';
import App from './App.vue';
//导入
import http from 'axios'
import '../api/config'
http.defaults.baseURL = 'https://XXXXXXX';//服务器地址
//请求头声明
http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
http.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded';
Vue.prototype.$http=http;
Vue.config.productionTip = false
new Vue({
el:'#app',
render: h => h(A

本文介绍如何在vue.js项目中封装axios,并结合tp5进行路由设置,同时讲解如何去除index.php前缀。建议配合提供的源码进行学习。
订阅专栏 解锁全文
649

被折叠的 条评论
为什么被折叠?



