发表于: 2021-04-09 19:51:34

1 2387


今天完成的事情:从服务器请求登陆数据

明天计划的事情:写第二个页面的JS部分

收获:

angular http 跨域访问

1、在根目录中创建配置文件:proxy.config.json 

{
    "/gpcweb": {
        "target""http://dev.admin.carrots.ptteng.com/",
        "secure""false",
        "changeOrigin":true,
        "pathRewrite": {
            "^/api"""
        }
    }
}

2、修改 package.json 配置文件内容

"start""ng serve --proxy-config proxy.config.json",

3、启动项目

npm start

4、angular http 请求

var api = "http://dev.admin.carrots.ptteng.com/a/login";
this.http.get(api).subscribe((response: any=> {
  console.log(response);
  this.list = response.result;
});



返回列表 返回列表
评论

    分享到