uni-app请求网络数据(POST\GET)

 POST请求:

发起网络POST请求

methods:{
			requestData(){
				uni.request({
				    url: 'http://api.komavideo.com/news/list',
				    method:'POST',
					data: {
				        pageSize:2
				    },
				    header: {
				        'custom-header': 'hello' //自定义请求头信息
				    },
				    success: (res) => {
				        console.log(res.data);
				    }
				});
			}
		}

GET请求:

发起网络POST请求

methods:{
			requestData(){
				uni.request({
				    url: 'http://api.komavideo.com/news/list',
				    method:'GET',
					data: {
				        
				    },
				    header: {
				        'custom-header': 'hello' //自定义请求头信息
				    },
				    success: (res) => {
				        console.log(res.data);
				    }
				});
			}
		}

详细请求网络数据介绍,官方地址链接:https://uniapp.dcloud.io/api/request/request?id=request

你可能感兴趣的:(uni-app)