uniapp请求跨域解决方案

uniapp框架跨域配置

打开uniapp的配置文件manifest.json 找到h5

  • 开始配置
    "h5" : {
        "title" : "年货节-年终爆品盘点",
        "router" : {
            "mode" : "hash",
            "base" : "./"
        },
        "devServer" : {
            "port" : 8801, 
            "disableHostCheck" : true,
            "proxy" : {
                "/ksy" : {
                    "target" : "https://192.168.1.1:8801/zklystore",
                    "changeOrigin" : true, 
                    "ws" : true, 
                    "pathRewrite" : {
                        "^/ksy" : ""
                    }
                }
            }
        }
    }

使用

uni.request({ url:"/ksy/activeapi/getAllproductinactive", method:"GET", success:res=>{ } })

posted @ 2021-01-29 09:08  小泽沐优声  阅读(687)  评论(0编辑  收藏  举报