vue 中拿来即用的Axios请求语法

get请求

let url = "";
        this.$axios({
          url: url,
          method: "get",
          params: {
            a: 1,
            b: 2
          },
        }).then((res) => {
          console.log(res);
        }).catch(function(error) {
          //  this.$message.error(error);
        });

 post请求

        var url = "";
        this.$axios({
          url: url,
          data: {
            a: 1
          },
          headers: {'Content-Type': 'application/json'},
          method: "post",
        }).then((res) => {
          
          console.log(res);
        });

 以上代码是拿来复制粘贴用的,仅用来做笔记

posted @ 2020-11-03 10:36  li阿根  阅读(229)  评论(0编辑  收藏  举报