1、在package.json文件同级目录下新建 vue.config.js
module.exports = { devServer: { proxy: { '/ajax': { target: 'https://m.maoyan.com', //后台接口域名 // ws: true, //如果要代理 websockets,配置这个参数 changeOrigin: true //是否跨域 }, // '/foo': { // target: '<other_url>' // } } } }
最后修改配置文件记得重启服务