uni.request發起網絡請求
url
開發者服務器接口地址
data
請求的參數
header
method
dataType
responseType
設置響應的數據類型
statusCode 開發者服務器返回的http狀態碼
data數據說明
<template>
<view></view>
</template>
// get
const requestTask1 = uni.request({
url: ' ',
success: function(res) {
console.log(res.data);
}
});
//
const requestTask2 = uni.request({
url :''
data:{},
method: 'POST',
header: {'content-type': 'application/x-www-form-urlencoded'},
success: function(res){
}
header['content-type'] 為 application/json 的數據,會進行 JSON 序列化
若本號內容有做得不到位的地方(比如:涉及版權或其他問題),請及時聯系我們進行整改即可,會在第一時間進行處理。
請點贊!因為你們的贊同/鼓勵是我寫作的最大動力!
歡迎關注達達的簡書!
這是一個有質量,有態度的博客