就本地把代理连到线上地址就行了,现在如果开启了8081是把/api 代理到8081服务,线上的话就改成 111.111.111.111/api这样一个地址。
以上是你自己本地测试的情况,假如要提供环境给团队其他人用,可以直接在服务器上部署npm run dev,同样要把代理写对。
代理是在 config/index.js
dev: {
env: require('./dev.env'),
port: 8888,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': 'http://localhost:8889'
},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}