vue.config.js文件——配置参考
// vue.config.js文件详解
module.exports = {
//本地验证接口时用
//—————————————————--------------------------------------------
runtimeCompiler: true, //是否使用包含运行时编译器的Vue内核版本
lintOnSave: false,
//publicPath: '/dist/',
//outputDir: './dist',
transpileDependencies: [
'vue-socket.io',
'vue-echarts',
'resize-detector',
],
devServer: { // 所有 webpack-dev-server 的选项都支持
open: true, //配置自动启动浏览器
// host: 'localhost',
host: '0.0.0.0', // 本地ip地址
port: 8080, // 端口号
hot: true, // 自动打开浏览器
disableHostCheck: true,
https: false,
//以上的ip和端口是我们本机的;下面为需要跨域的
proxy: { // 跨域代理
//配置跨域
'/api': {
target: 'http://10.88.155.45:9910/rest/', // 目标代理服务器地址
// target: 'http://localhost:3000/rest/', //node模拟数据:这里后台的地址模拟的;应该填写你们真实的后台接口
ws: true, // 如果要代理 websockets,配置这个参数
changOrigin: true, //允许跨域
pathRewrite: {
'^/api': '' //请求的时候使用这个api就可以 去掉接口地址中的api字符串
}
}
}
}
}