解决前后端的跨域问题:Access to XMLHttpRequest at '**' from origin '**' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
报错信息:
Access to XMLHttpRequest at 'http://localhost:8182/cooperationRequest/getList' from origin 'http://localhost:3004' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


解决方法:
在项目根目录下新建vue.config.js文件
module.exports = { devServer: { proxy: { '/api': { target: 'http://127.0.0.1:8182/api/',// 后端接口 changeOrigin: true, // 是否跨域 pathRewrite: { '/api': '' } } } } }

浙公网安备 33010602011771号