问题描述:vue中使用域名访问接口时报错。
访问方式:
报错信息:
解决方法:项目目录configs中找到config.js文件中增加:
const config = {
dev:{
proxyTable: { //处理跨域使用
'/api': { //使用"/api"来代替"https://****.*****.com/"
target: 'https://****.*****.com/', //源地址
changeOrigin: true, //改变源
pathRewrite: {
'^/api': ''
}
}
},
}
}
请求方法改为:
即可