首页 > 其他 > 详细

vue3脚手架设置跨越

时间:2020-05-07 22:05:03      阅读:81      评论:0      收藏:0      [点我收藏+]

vue3-cli配置跨域

 

1.在vue.config.js中配置

 

module.exports = {

    devServer: {

        proxy: {

            ‘/api‘: {

                target: ‘http://22.163.72.64‘, //跨越的对应服务器地址

                changeOrigin: true, //允许跨域

                ws: true,

                pathRewrite: {

                    ‘^/api‘: ‘‘
                }
            }
        }
    }
}    

 

 

2.发送请求

 

axios.get("api/test/login")
.then((res) => {
    console.log(res)
})

// 相当于

axios.get("http://22.163.72.64/test/login")
.then((res) => {
console.log(res)
})

 

vue3脚手架设置跨越

原文:https://www.cnblogs.com/zxuedong/p/12845579.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!