美文网首页
uni app 跨域

uni app 跨域

作者: 上海_前端_求内推 | 来源:发表于2021-09-24 09:24 被阅读0次

1,在manifest.json新增

  "h5" : {
        "devServer" : {
            "disableHostCheck" : true,
            "proxy" : {
                "/api" : {
                    "target" : "http://192.192.192.183:9798",
                    "changeOrigin" : true,
                    "secure" : false,
                    "pathRewrite" : {
                        "^/api" : "/"
                    }
                }
            }
        }
    }

2,请求接口时api代替源地址

    getList(index) {
                         // api等价于http://192.192.192.183:9798
                this.$request('/api/eurekamedicalsystem/v2/medical-emrquality/seconditem', {
                    // 传参参数名:参数值,如果没有,就不需要传
                    "wardCode": index,
                    // "key": this.searchValue
                }).then(res => {
                    // 打印调用成功回调
                    console.log(res)
                    this.datalist = res;
                })
            },

相关文章

网友评论

      本文标题:uni app 跨域

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