Vue-axios的基本使用(一)

Vue-axios的基本使用 一

axios请求方式

支持多种请求方式:

  • axios(config)
  • axios.request(config)
  • axios.get(url[,config])
  • axios.delete(url[,config])
  • axios.head(url[,config])
  • axios.post(url[,data[,config]])
  • axios.put(url[,data[,config]])
  • axios.patch(url[,data[,config]])

重点讲解axios(config)

//1.
axios({
	//httpbin.org网站可以模拟传参
	url:'httpbin.org',
	//method:'可以指定请求类型(默认为get)'
	method:'get'
	//then是用来拿到res(结果)
}).then(res =>{ 
	//打印结果
	console.log(res);
})
//2.如果url中有参数
axios({
	url:'http://123.111.32.32:8000/home/data?type=sell&page=3'
}).then(res => {
	console.log(res);
})
//还有一种方法
axios({
	url:'http://123.111.32.32:8000/home/data',
	params: {
	type:'pop'
	page:'1'
}
}).then(res => {
	console.log(res);
})
//3.
axios.get(url,对应的其他配置).then({

})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值