2021-04-10Axios的get方式
2021-04-10 本文已影响0人
swp小小喀嚓鱼
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);
})