当前位置: 首页 > 工具软件 > tp5-vue > 使用案例 >

【tp5+vue】 (附带源码)

郝池暝
2023-12-01

说明: 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(App),
});

注入拦截器:

import http from &
 类似资料: