1.配置config->index.js
// dev: 中
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': { // 這個api爲自定義的字符串,相當於'/api' == 'http://192.168.123.130:9979'
target: 'http://192.168.123.130:9979', // 需要跨域的地址以及端口名,後面不能帶/
changeOrigin: true, //是否跨域
pathRewrite: {
'^/api': '/' //這裏相當於用/代替target中的地址,使用時get('/api/login')
}
}
},