module.exports = {
devServer: {
proxy: {
'/api': {
'target': 'http://120.53.31.103:84/api/app/',
'changeOrigin': true,
'pathRewrite': { '^/api' : '' },
},
}
},
css: {
loaderOptions: {
css: {},
postcss: {
plugins: [
require("postcss-px2rem")({
remUnit: 37.5
})
]
}
}
}
};
- axios的封装
- 创建一个http.js
- 编辑公共地址和请求拦截,响应拦截
import axios from "axios";
import { Toast } from 'vant'
const http=axios.create({
baseURL:'/api',
withCredentials:true,
timeout:5000
})
http.interceptors.request.use(config => {
Toast.loading({
message: '加载中...',
forbidClick: true,
});
return config
}, err => {
console.log(err)
})
http.interceptors.response.use(res => {
Toast.clear()
return res = res.data
}, err => {
console.log(err)
})
export default http
import api from "./http";
export default function requests({method='get',url='',data={},params={}}){
return api({
method,
url,
data,
params
})
}
import req from './api'
export const test = (data) => req({ url: 'recommend/appIndex', data })
export const GetvCode = (data) => req({ url: 'smsCode', method: 'post', data })
export const getLogin = (data) => req({ url: 'login', method: 'post', data })
export const GitMing = () => req({ url: 'recommend/appIndex' })
export const getAppoint = () => req({ url: 'teacher/search/attrs' })
export const getSwipe = () => req({ url: 'banner' })
export const getPwd = (data) => req({url:'password',method:'post',data})
发布不易请点赞~~原创,谢谢大家