美文网首页
vue-cli3.x vue.config.js 跨域配置

vue-cli3.x vue.config.js 跨域配置

作者: Hello杨先生 | 来源:发表于2019-11-09 14:42 被阅读0次
devServer: {
        open: true, //浏览器自动打开页面
        host: "0.0.0.0", //如果是真机测试,就使用这个IP
        port: 8911,
        https: false,
        hotOnly: false, //热更新(webpack已实现了,这里false即可)
        proxy: {
            //配置跨域
            '/api': {
                target: "http://139.224.234.237:3000/api",
                ws:true,
                changOrigin:true,
                pathRewrite:{
                    '^/api':'/'
                }
            }
        }
    }
//调用
this.$http.get('/api/order/getOrder')
        .then(res => {
          console.log(res.data);
        })
        .catch(err => {
          console.log(err.data.message);
        });

相关文章

网友评论

      本文标题:vue-cli3.x vue.config.js 跨域配置

      本文链接:https://www.haomeiwen.com/subject/rhhnbctx.html