vue-axios的使用

   //get请求
    axios
      .get("json/getDate.json", {
        params: { id: 50 }
      })
      .then(res => {
        console.log(res);
      });
    axios({
      method: "get",
      url: "json/getDate.json",
      params: { id: 10 }
    }).then(res => {
      console.log(res);
    });

    //post请求的格式有
    //application/json:
    //form-data:表单提交(图片上传和文件上传)
    let filter = { name: "55" };
    axios.post("json/postDate.json", filter).then(res => {
      console.log(res);
    });
    //http://localhost:8080/json/postDate.json?goodname=sun
    axios({
      method: "post",
      url: "json/postDate.json",
      data: filter,
      params: { goodname: "sun" }
    }).then(res => {
      console.log(res);
    });

    //form-data请求
    let formData = new FormData();
    for(let key in filter){
        formData.append(key,filter[key])
    }
    axios.post("json/postDate.json",formData).then(res => {
      console.log(res);
    });

    //patch请求
        axios.patch("json/path.json",filter).then(res => {
      console.log(res);
    });
       //put
    axios.put("json/put.json",filter).then(res => {
      console.log(res);
    });
  }
原文地址:https://www.cnblogs.com/lvlvlv/p/11767689.html