可以在vue.config.js文件中配置代理,写法和vue2是一样的; // vue.config.js module.exports = { // 修改的配置 // 将baseUrl: '/api',改为baseUrl: '/', baseUrl: '/', devServer: { proxy: { '/api': { target: 'http://www.example.org', changeOrigin: true, ws: true, pathRewrite: { '^/api': '' } } } } } // .env.development VUE_APP_BASE_API=/api
可以在vue.config.js文件中配置代理,写法和vue2是一样的;