vue本地接口跨域常用方法

1、axios请求withCredentials: true | axios.defaults.withCredentials = true(跨域请求带上cookies)

     let param = {};
      param.cardNo = "test02";

      axios
        .get(global_config.BASE_URL_U + "/webService/getReaderInfo", {
          params: param,
          withCredentials: true
        })
        .then(function(response) {
          debugger;
          let result = response.result;
        });

2、vue_cli 设置代理

  proxyTable: {
      "/webService": {
        target: "http://opac.jxlibrary.net:8082",
        changeOrigin: true,
        // pathRewrite: {
        //   '^/api': '/' //重写接口,可以为空'',也可以为'/'
        // }
      }
    },

 

你可能感兴趣的:(vue.js,javascript)