// manifest.json
"h5": {
"devServer": {
"port": 8080, //端口号
"disableHostCheck": true,
"proxy": {
"/api": {
"target": "https://aip.baidubce.com/oauth/2.0/token", //目标接口域名
"changeOrigin": true, //是否跨域
"secure": false, // 设置支持https协议的代理
"pathRewrite": {
"^/api": ""
}
}
// "/text": {
// "target": "https://fanyi-api.baidu.com/api/trans/vip/translate", //目标接口域名
// "changeOrigin": true, //是否跨域
// "secure": false, // 设置支持https协议的代理
// "pathRewrite": {
// "^/text": ""
// }
// }
}
},
"optimization": {
"treeShaking": {
"enable": false
}
}
}
//页面中请求的时候吧url改成上面定义的
console.log('点击翻译文本', data)
uni.request({
url: '/text',
data,
success(res) {
console.log(res)
}
})
修改完后重启项目!!!