参考:https://blog.csdn.net/weixin_43216105/article/details/98877960
我的在uniapp中配置
vue.config.js
module.exports = {
// 输出目录
assetsDir: 'static',
// 基本路径
// baseUrl: './',
devServer: {
proxy: {
'/seeu': {
target: 'https://www.seeu.net.cn', //对应自己的接口
changeOrigin: true,
ws: true,
pathRewrite: {
'^/seeu': '' //忽略api前缀
}
},
'/video': {
target: 'https://www.bilibili.com/', //对应自己的接口
changeOrigin: true,
ws: true,
pathRewrite: {
'^/video': '' //忽略api前缀
}
},
}
}
}
api.js
import http from '../utils/http'
//
/**
* @parms resquest 请求地址 例如:http://197.82.15.15:8088/request/...
* @param '/testIp'代表vue-cil中config,index.js中配置的代理
*/
let request = "/music/cloudmusic/"
// get请求
function getListAPI(params){
return http.get(`${request}`,params)
}
// post请求
function postFormAPI(params){
return http.post(`${request}`,params)
}
// put 请求
function putSomeAPI(params){
return http.put(`${request}`,params)
}
// delete 请求
function deleteListAPI(params){
return http.delete(`${request}`,params)
}
export default{
getListAPI,
postFormAPI,
putSomeAPI,
deleteListAPI
}