美文网首页
2021-04-10Axios的get方式

2021-04-10Axios的get方式

作者: swp小小喀嚓鱼 | 来源:发表于2021-04-10 14:23 被阅读0次

    axios(url[, config])

    axios(),直接用url

      axios("http://wthrcdn.etouch.cn/weather_mini?city=成都")
      .then(function (response) {    
        console.log('one1======='+response.data);
        console.log(response)
      });
    

    axios(),直接用config

      axios({
      method: 'get',
      url: "http://wthrcdn.etouch.cn/weather_mini?city=成都" 
    })
      .then(function (response) {
        console.log('one2======='+response.data);
        console.log(response)
      });
    

    axios.get(url[, config])

    axios.get(),直接用url

      axios.get("http://wthrcdn.etouch.cn/weather_mini?city=成都")
      .then(function (response) {
            console.log('one3======='+response.data);  
            console.log(response)     
      })
      .catch(function (error) {    
        console.log(error);
      })
    

    axios.get(),用params

      axios.get('http://wthrcdn.etouch.cn/weather_mini', {
        params: {
          city: '成都'
        }
      })
      .then(function (response) {
        console.log('one4======='+response.data);
        console.log(response)
      })
      .catch(function (error) {
        console.log(error);
      })
    

    相关文章

      网友评论

          本文标题:2021-04-10Axios的get方式

          本文链接:https://www.haomeiwen.com/subject/pfcnkltx.html