关于vue如何调用后端接口

前端数据调用接口问题

getSource() {
    
    
      console.log("1111");
      var vm = this;
      vm.$http
//这个post里面就是要调用的接口
//下面的字段就是要通过什么数据查询
        .post("具体调用的接口", {
    
    
          接需要的字段名: "字段",
        })
        .then((response) => {
    
    
          console.log("返回的数据", response.data);
          switch (response.code) {
    
    
            case "0000":
              this.student = response.data;
              console.log(this.student);

              break;
            case "1111":
              console.log("查询失败");
              break;
          }
        });

Guess you like

Origin blog.csdn.net/weixin_44459831/article/details/121033726