1、在vue.config.js中配置proxy
module.exports = { publicPath: '/', outputDir: "dist", devServer: { proxy: { '/api': { target: 'http://m.renyiwenzhen.com/', changeOrigin: true, pathRewrite: { "/api": '' } } } } };
2、组件里面请求,补全接口地址
get(){ this.axios.get('api/xcx_ajax.php?action=babylist').then(res =>{ console.log(res); } }
3、成功
刚干前端没多久,欢迎指正。