## 跨域问题
> 协议,域名,端口号不一致
### 项目根目录新建vue.config.js
```js
module.exports = {
devServer:{
open:true,
// host:'localhost',
// port:8080,
// https:false,
// hotOnly:false,
proxy:{
'/api':{
target:"http://web.juhe.cn",
changeOrigin:true,
pathRewrite:{
'^/api':''
}
}
}
}
}
```
### 定义全局变量
```js
Vue.prototype.HOST = '/api'
```
### HOST添加到请求方法中