- 更改vue.config.js
publicPath: process.env.NODE_ENV === 'production' ? '/tyzfadmin' : '/',//开发和生产环境不一样,做个判断
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: false,
runtimeCompiler: true,
productionSourceMap: false,
devServer: {
port: port,
open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'/api': {
target: 'http://127.0.0.1:8080', // 后端地址
changeOrigin: true, // 开启代理,在本地创建一个虚拟服务端
pathRewrite: {
'^/api': '/'
}
}
}
// before: require('./mock/mock-server.js')
},
- 更改request.js
3. 更改 .env.development
# just a flag
ENV = 'development'
# base api
# VUE_APP_BASE_API = '/api'
VUE_APP_BASE_API = 'http://127.0.0.1:8080'//和proxy中的target一致