vue.config.js
是一个可选的配置文件,如果项目的 (和 package.json
同级的) 根目录中存在这个文件,那么它会被 @vue/cli-service
自动加载。
module.exports = {
devServer: {
open: true,
host: 'localhost',
port: 8080,
https: false,
proxy: {
//配置跨域
'/api': {
target: 'http://localhost:8000/',
ws: true,
changOrigin: true, //允许跨域
pathRewrite: {
'^/index/recommentProjects': '^/index/recommentProjects'
}
}
}
}
}
注意每次都必须重启。