欧美性猛交xxxx免费看_牛牛在线视频国产免费_天堂草原电视剧在线观看免费_国产粉嫩高清在线观看_国产欧美日本亚洲精品一5区

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙OS開發(fā)實例:【窺探網(wǎng)絡(luò)請求】

jf_46214456 ? 2024-04-01 16:11 ? 次閱讀

HarmonyOS 平臺中使用網(wǎng)絡(luò)請求,需要引入 "@ohos.net.http", 并且需要在 module.json5 文件中申請網(wǎng)絡(luò)權(quán)限, 即 “ohos.permission.INTERNET”

本篇文章將嘗試使用 @ohos.net.http 來實現(xiàn)網(wǎng)絡(luò)請求

場景設(shè)定

  1. WeiBo UniDemo HuaWei : 請求順序
  2. WeiBo1 UniDemo2 HuaWei3 : 異步/同步請求時,序號表示請求回來的順序
  3. “開始網(wǎng)絡(luò)請求-異步” : 開始異步請求
  4. “開始網(wǎng)絡(luò)請求-同步” : 開始同步請求
  5. “開始網(wǎng)絡(luò)請求-自定義方法裝飾器” : 采用自定義方法裝飾器進行傳參,進而完成網(wǎng)絡(luò)請求

官方網(wǎng)絡(luò)請求案例

注意:

每次請求都必須新創(chuàng)建一個HTTP請求實例,即只要發(fā)起請求,必須調(diào)用createHttp方法

更多鴻蒙開發(fā)應(yīng)用知識已更新qr23.cn/AKFP8k參考前往。

搜狗高速瀏覽器截圖20240326151547.png

關(guān)于 @ohos.net.http 有三個request方法

可+mau123789獲取鴻蒙文檔
  1. request(url: string, callback: AsyncCallback): void;
    1.1 如下“官方指南代碼縮減版”使用到了這個方法
  2. request(url: string, options: HttpRequestOptions, callback: AsyncCallback): void;
    2.1 如下“官方指南代碼” 使用了這個方法
  3. request(url: string, options?: HttpRequestOptions): Promise;
    3.1 將在后續(xù)實踐代碼中使用到
// 引入包名
import http from '@ohos.net.http';

// 每一個httpRequest對應(yīng)一個HTTP請求任務(wù),不可復(fù)用
let httpRequest = http.createHttp();
// 用于訂閱HTTP響應(yīng)頭,此接口會比request請求先返回。可以根據(jù)業(yè)務(wù)需要訂閱此消息
// 從API 8開始,使用on('headersReceive', Callback)替代on('headerReceive', AsyncCallback)。 8+
httpRequest.on('headersReceive', (header) = > {
    console.info('header: ' + JSON.stringify(header));
});
httpRequest.request(
    // 填寫HTTP請求的URL地址,可以帶參數(shù)也可以不帶參數(shù)。URL地址需要開發(fā)者自定義。請求的參數(shù)可以在extraData中指定
    "EXAMPLE_URL",
    {
        method: http.RequestMethod.POST, // 可選,默認為http.RequestMethod.GET
        // 開發(fā)者根據(jù)自身業(yè)務(wù)需要添加header字段
        header: {
            'Content-Type': 'application/json'
        },
        // 當(dāng)使用POST請求時此字段用于傳遞內(nèi)容
        extraData: {
            "data": "data to send",
        },
        expectDataType: http.HttpDataType.STRING, // 可選,指定返回數(shù)據(jù)的類型
        usingCache: true, // 可選,默認為true
        priority: 1, // 可選,默認為1
        connectTimeout: 60000, // 可選,默認為60000ms
        readTimeout: 60000, // 可選,默認為60000ms
        usingProtocol: http.HttpProtocol.HTTP1_1, // 可選,協(xié)議類型默認值由系統(tǒng)自動指定
    }, (err, data) = > {
        if (!err) {
            // data.result為HTTP響應(yīng)內(nèi)容,可根據(jù)業(yè)務(wù)需要進行解析
            console.info('Result:' + JSON.stringify(data.result));
            console.info('code:' + JSON.stringify(data.responseCode));
            // data.header為HTTP響應(yīng)頭,可根據(jù)業(yè)務(wù)需要進行解析
            console.info('header:' + JSON.stringify(data.header));
            console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
        } else {
            console.info('error:' + JSON.stringify(err));
            // 取消訂閱HTTP響應(yīng)頭事件
            httpRequest.off('headersReceive');
            // 當(dāng)該請求使用完畢時,調(diào)用destroy方法主動銷毀
            httpRequest.destroy();
        }
    }
);
// 引入包名
import http from '@ohos.net.http';

// 每一個httpRequest對應(yīng)一個HTTP請求任務(wù),不可復(fù)用
let httpRequest = http.createHttp();

httpRequest.request(
    // 填寫HTTP請求的URL地址,可以帶參數(shù)也可以不帶參數(shù)。URL地址需要開發(fā)者自定義。請求的參數(shù)可以在extraData中指定
    "EXAMPLE_URL",
    (err, data) = > {
        if (!err) {
            // data.result為HTTP響應(yīng)內(nèi)容,可根據(jù)業(yè)務(wù)需要進行解析
            console.info('Result:' + JSON.stringify(data.result));
            console.info('code:' + JSON.stringify(data.responseCode));
            // data.header為HTTP響應(yīng)頭,可根據(jù)業(yè)務(wù)需要進行解析
            console.info('header:' + JSON.stringify(data.header));
            console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
        } else {
            console.info('error:' + JSON.stringify(err));
            // 取消訂閱HTTP響應(yīng)頭事件
            httpRequest.off('headersReceive');
            // 當(dāng)該請求使用完畢時,調(diào)用destroy方法主動銷毀
            httpRequest.destroy();
        }
    }
);

場景布局

基礎(chǔ)頁面組件代碼

考慮到實際的場景會用到網(wǎng)絡(luò)請求加載,因此這里將發(fā)揮 [@BuilderParam] 裝飾器作用,先定義基礎(chǔ)頁面

組件中定義了 @Prop netLoad:boolean 變量來控制是否展示加載動畫

@Component
export struct BasePage {
  @Prop netLoad: boolean

  //指向一個組件  
  @BuilderParam aB0: () = > {}

  build(){
     Stack(){
       
       //為組件占位
       this.aB0()

       if (this.netLoad) {
         LoadingProgress()
           .width(px2vp(150))
           .height(px2vp(150))
           .color(Color.Blue)
       }

     }.hitTestBehavior(HitTestMode.None)
  }

}

主頁面布局代碼

import { BasePage } from './BasePage'

@Entry
@Component
struct NetIndex {
  @State netLoad: number = 0
  @State msg: string = ''

  build() {
      Stack(){
        BasePage({netLoad: this.netLoad != 0}) {
          Column( {space: 20} ){

            Row({space: 20}){
              Text('WeiBo').fontColor(Color.Black)
              Text('UniDemo').fontColor(Color.Black)
              Text('HuaWei').fontColor(Color.Black)
            }

            Row({space: 20}){
              Text('WeiBo' + this.weiboIndex)
              Text('UniDemo' + this.uniIndex)
              Text('HuaWei' + this.huaweiIndex)
            }

            Button('開始網(wǎng)絡(luò)請求 - 異步').fontSize(20).onClick( () = > {
                ...
            })

            Button('開始網(wǎng)絡(luò)請求 - 同步').fontSize(20).onClick( () = > {
                ...
            })

            Button('開始網(wǎng)絡(luò)請求-自定義方法裝飾器').fontSize(20).onClick( () = > {
              ...
            })

            Scroll() {
              Text(this.msg).width('100%')
            }
            .scrollable(ScrollDirection.Vertical)
          }
          .width('100%')
          .height('100%')
          .padding({top: px2vp(120)})
        }

      }
  }

}

簡單裝封裝網(wǎng)絡(luò)請求

函數(shù)傳參,直接調(diào)用封裝方法

WeiBo為數(shù)據(jù)結(jié)構(gòu)體,暫時不用關(guān)心,后續(xù)會貼出完整代碼,這里僅僅是演示網(wǎng)絡(luò)請求用法

//引用封裝好的HNet網(wǎng)絡(luò)工具類
import HNet from './util/HNet'

@State msg: string = ''
    
getWeiBoData(){
   HNet.get< WeiBo >({
  url: 'https://m.weibo.cn/api/feed/trendtop?containerid=102803_ctg1_4188_-_ctg1_4188',
}).then( (r) = > {

  this.msg = ''

  if(r.code == 0 && r.result){
    r.result.data.statuses.forEach((value: WeiBoItem) = > {
      this.msg = this.msg.concat(value.created_at + ' ' + value.id + 'n')
    })
  } else {
    this.msg = r.code + ' ' + r.msg
  }
  console.log('順序-weibo-' + (new Date().getTime() - starTime))

  this.netLoad--

})    
   
}

自定義方法裝飾器,完成傳參調(diào)用

網(wǎng)絡(luò)請求樣例

NetController.getWeiBo< WeiBo >().then( r = > {
   ......
})    
復(fù)制

按照業(yè)務(wù)定義傳參

import { Get, NetResponse } from './util/HNet'

export default class BizNetController {

  @Get('https://m.weibo.cn/api/feed/trendtop?containerid=102803_ctg1_4188_-_ctg1_4188')
  static getWeiBo< WeiBo >(): Promise< NetResponse< WeiBo >>{ return }

}
復(fù)制

封裝的網(wǎng)絡(luò)請求代碼

import http from '@ohos.net.http';

//自定義網(wǎng)絡(luò)請求參數(shù)對象    
class NetParams{
  url: string
  extraData?: JSON
}

//自定義數(shù)據(jù)公共結(jié)構(gòu)體    
export class NetResponse< T > {
  result: T
  code: number
  msg: string
}

//網(wǎng)絡(luò)封裝工具類    
class HNet {

  //POST 請求方法  
  static post< T >(options: NetParams): Promise< NetResponse< T >>{
    return this.request(options, http.RequestMethod.POST)
  }

  //GET 請求方法  
  static get< T >(options: NetParams): Promise< NetResponse< T >>{
    return this.request(options, http.RequestMethod.GET)
  }

    
  private static request< T >(options: NetParams, method: http.RequestMethod): Promise< NetResponse< T >>{

    let r = http.createHttp()

    return r.request(options.url, {
      method: method,
      extraData: options.extraData != null ? JSON.stringify(options.extraData) : null
    }).then( (response: http.HttpResponse) = > {

      let netResponse = new NetResponse< T >()

      let dataType = typeof response.result

      if(dataType === 'string'){
         console.log('結(jié)果為字符串類型')
      }

      if(response.responseCode == 200){
        netResponse.code = 0
        netResponse.msg = 'success'
        netResponse.result = JSON.parse(response.result as string)

      } else {
        //出錯
        netResponse.code = -1
        netResponse.msg = 'error'

      }

      return netResponse

    }).catch( reject = > {
      console.log('結(jié)果發(fā)生錯誤')

      let netResponse = new NetResponse< T >()
      netResponse.code = reject.code
      netResponse.msg  = reject.message
      return netResponse

    }).finally( () = > {
       //網(wǎng)絡(luò)請求完成后,需要進行銷毀
       r.destroy()
    })

  }

}

export default HNet 
    
//用于裝飾器傳參
export function Get(targetUrl: string) : MethodDecorator {

  return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) = > {
        //替換方法
        descriptor.value = () = > {
           let options = new NetParams()
           options.url = targetUrl
            return HNet.get(options)
        }
  }

}

完整代碼

代碼結(jié)構(gòu)

net/BasePage.ets

net/NetRequest.ets

net/util/HNet.ts

net/viewmodel/WeiBoModel.ts

net/BizNetController.ets

詳細代碼

@Component
export struct BasePage {
  @Prop netLoad: boolean

  @BuilderParam aB0: () = > {}

  build(){
     Stack(){

       this.aB0()

       if (this.netLoad) {
         LoadingProgress()
           .width(px2vp(150))
           .height(px2vp(150))
           .color(Color.Blue)
       }

     }.hitTestBehavior(HitTestMode.None)
  }

}
import HNet from './util/HNet'
import NetController from './BizNetController'
import { WeiBo, WeiBoItem } from './viewmodel/WeiBoModel'
import { BasePage } from './BasePage'

@Entry
@Component
struct NetIndex {
  @State netLoad: number = 0
  @State msg: string = ''

  @State weiboColor: Color = Color.Black
  @State uniColor: Color = Color.Black
  @State huaweiColor: Color = Color.Black

  @State weiboIndex: number = 1
  @State uniIndex: number = 2
  @State huaweiIndex: number = 3

  private  TEST_Target_URL: string[] = [
    'https://m.weibo.cn/api/feed/trendtop?containerid=102803_ctg1_4188_-_ctg1_4188',
    'https://unidemo.dcloud.net.cn/api/news',
    'https://developer.huawei.com/config/cn/head.json',
  ]

  build() {
      Stack(){
        BasePage({netLoad: this.netLoad != 0}) {
          Column( {space: 20} ){

            Row({space: 20}){
              Text('WeiBo').fontColor(Color.Black)
              Text('UniDemo').fontColor(Color.Black)
              Text('HuaWei').fontColor(Color.Black)
            }

            Row({space: 20}){
              Text('WeiBo' + this.weiboIndex).fontColor(this.weiboColor)
              Text('UniDemo' + this.uniIndex).fontColor(this.uniColor)
              Text('HuaWei' + this.huaweiIndex).fontColor(this.huaweiColor)
            }

            Button('開始網(wǎng)絡(luò)請求 - 異步').fontSize(20).onClick( () = > {
                this.weiboColor = Color.Black
                this.uniColor = Color.Black
                this.huaweiColor = Color.Black
                this.weiboIndex = 1
                this.uniIndex = 2
                this.huaweiIndex = 3
                this.asyncGetData()
            })

            Button('開始網(wǎng)絡(luò)請求 - 同步').fontSize(20).onClick( () = > {
                this.weiboColor = Color.Black
                this.uniColor = Color.Black
                this.huaweiColor = Color.Black

                this.weiboIndex = 1
                this.uniIndex = 2
                this.huaweiIndex = 3
                this.syncGetData()
            })

            Button('開始網(wǎng)絡(luò)請求-自定義方法裝飾器').fontSize(20).onClick( () = > {
              this.getWeiBoListByController()
            })

            Scroll() {
              Text(this.msg).width('100%')
            }
            .scrollable(ScrollDirection.Vertical)
          }
          .width('100%')
          .height('100%')
          .padding({top: px2vp(120)})
        }

      }
  }

  asyncGetData(){

    this.netLoad = 3;

    this.TEST_Target_URL.forEach( (value) = > {

      HNet.get({
        url: value,
      }).then( (r) = > {

        this.msg = JSON.stringify(r)

        if(value.indexOf('weibo') != -1){
          this.weiboColor = Color.Green
          this.weiboIndex = 3 - this.netLoad + 1
        } else if(value.indexOf('unidemo') != -1){
          this.uniColor = Color.Green
          this.uniIndex = 3 - this.netLoad + 1
        } else if(value.indexOf('huawei') != -1){
          this.huaweiColor = Color.Green
          this.huaweiIndex = 3 - this.netLoad + 1
        }

        this.netLoad--

      })
    })

  }

  async syncGetData() {

    let starTime
    let url
    this.netLoad = 3;

    starTime = new Date().getTime()
    url = this.TEST_Target_URL[0]

    starTime = new Date().getTime()
    if(url.indexOf('weibo') != -1){
      console.log('順序-請求-weibo')
    } else if(url.indexOf('unidemo') != -1){
      console.log('順序-請求-unidemo')
    } else if(url.indexOf('huawei') != -1){
      console.log('順序-請求-huawei')
    }

    await HNet.get< WeiBo >({
      url: url,
    }).then( (r) = > {

      this.msg = ''

      if(r.code == 0 && r.result){
        r.result.data.statuses.forEach((value: WeiBoItem) = > {
          this.msg = this.msg.concat(value.created_at + ' ' + value.id + 'n')
        })
      } else {
        this.msg = r.code + ' ' + r.msg
      }

      if(url.indexOf('weibo') != -1){
        this.weiboColor = Color.Green
        this.weiboIndex = 3 - this.netLoad + 1
        console.log('順序-返回-weibo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('unidemo') != -1){
        this.uniColor = Color.Green
        this.uniIndex = 3 - this.netLoad + 1
        console.log('順序-返回-unidemo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('huawei') != -1){
        this.huaweiColor = Color.Green
        this.huaweiIndex = 3 - this.netLoad + 1
        console.log('順序-返回-huawei-' + (new Date().getTime() - starTime))
      }

      this.netLoad--

    })

    starTime = new Date().getTime()
    url = this.TEST_Target_URL[1]

    starTime = new Date().getTime()
    if(url.indexOf('weibo') != -1){
      console.log('順序-請求-weibo')
    } else if(url.indexOf('unidemo') != -1){
      console.log('順序-請求-unidemo')
    } else if(url.indexOf('huawei') != -1){
      console.log('順序-請求-huawei')
    }

    await HNet.get({
      url: url,
    }).then( (r) = > {

      this.msg = JSON.stringify(r)

      if(url.indexOf('weibo') != -1){
        this.weiboColor = Color.Green
        this.weiboIndex = 3 - this.netLoad + 1
        console.log('順序-返回-weibo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('unidemo') != -1){
        this.uniColor = Color.Green
        this.uniIndex = 3 - this.netLoad + 1
        console.log('順序-返回-unidemo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('huawei') != -1){
        this.huaweiColor = Color.Green
        this.huaweiIndex = 3 - this.netLoad + 1
        console.log('順序-返回-huawei-' + (new Date().getTime() - starTime))
      }

      this.netLoad--

    })

    starTime = new Date().getTime()
    url = this.TEST_Target_URL[2]

    starTime = new Date().getTime()
    if(url.indexOf('weibo') != -1){
      console.log('順序-請求-weibo')
    } else if(url.indexOf('unidemo') != -1){
      console.log('順序-請求-unidemo')
    } else if(url.indexOf('huawei') != -1){
      console.log('順序-請求-huawei')
    }

    await HNet.get({
      url: url,
    }).then( (r) = > {

      this.msg = JSON.stringify(r)

      if(url.indexOf('weibo') != -1){
        this.weiboColor = Color.Green
        this.weiboIndex = 3 - this.netLoad + 1
        console.log('順序-返回-weibo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('unidemo') != -1){
        this.uniColor = Color.Green
        this.uniIndex = 3 - this.netLoad + 1
        console.log('順序-返回-unidemo-' + (new Date().getTime() - starTime))
      } else if(url.indexOf('huawei') != -1){
        this.huaweiColor = Color.Green
        this.huaweiIndex = 3 - this.netLoad + 1
        console.log('順序-返回-huawei-' + (new Date().getTime() - starTime))
      }

      this.netLoad--

    })

  }

  getHuaWeiSomeDataByNet(){

    this.netLoad = 1

    let starTime = new Date().getTime()

    console.log('順序-huawei-請求' + starTime)

    HNet.get({
      url: 'https://developer.huawei.com/config/cn/head.json',
    }).then( (r) = > {

      this.msg = JSON.stringify(r, null, 't')

      this.netLoad--

      console.log('順序-huawei-' + (new Date().getTime() - starTime))

    })

  }

  getWeiBoListByHNet(){

    this.netLoad = 1

    let starTime = new Date().getTime()

    console.log('順序-weibo-請求' + starTime)

    HNet.get< WeiBo >({
      url: 'https://m.weibo.cn/api/feed/trendtop?containerid=102803_ctg1_4188_-_ctg1_4188',
    }).then( (r) = > {

      this.msg = ''

      if(r.code == 0 && r.result){
        r.result.data.statuses.forEach((value: WeiBoItem) = > {
          this.msg = this.msg.concat(value.created_at + ' ' + value.id + 'n')
        })
      } else {
        this.msg = r.code + ' ' + r.msg
      }
      console.log('順序-weibo-' + (new Date().getTime() - starTime))

      this.netLoad--

    })
  }

  getWeiBoListByController(){

    this.netLoad = 1

    NetController.getWeiBo< WeiBo >().then( r = > {

      this.msg = ''

      if(r.code == 0 && r.result){
        r.result.data.statuses.forEach((value: WeiBoItem) = > {
          this.msg = this.msg.concat(value.created_at + ' ' + value.id + 'n' + value.source + 'n')
        })
      } else {
        this.msg = r.code + ' ' + r.msg
      }

      this.netLoad--

    })
  }

}
import { Get, NetResponse } from './util/HNet'

export default class BizNetController {

  @Get('https://m.weibo.cn/api/feed/trendtop?containerid=102803_ctg1_4188_-_ctg1_4188')
  static getWeiBo< WeiBo >(): Promise< NetResponse< WeiBo >>{ return }

}
import http from '@ohos.net.http';

class NetParams{
  url: string
  extraData?: JSON
}

export class NetResponse< T > {
  result: T
  code: number
  msg: string
}

class HNet {

  static post< T >(options: NetParams): Promise< NetResponse< T >>{
    return this.request(options, http.RequestMethod.POST)
  }

  static get< T >(options: NetParams): Promise< NetResponse< T >>{
    return this.request(options, http.RequestMethod.GET)
  }

  private static request< T >(options: NetParams, method: http.RequestMethod): Promise< NetResponse< T >>{

    let r = http.createHttp()

    return r.request(options.url, {
      method: method,
      extraData: options.extraData != null ? JSON.stringify(options.extraData) : null
    }).then( (response: http.HttpResponse) = > {

      let netResponse = new NetResponse< T >()

      let dataType = typeof response.result

      if(dataType === 'string'){
         console.log('結(jié)果為字符串類型')
      }

      if(response.responseCode == 200){
        netResponse.code = 0
        netResponse.msg = 'success'
        netResponse.result = JSON.parse(response.result as string)

      } else {
        //出錯
        netResponse.code = -1
        netResponse.msg = 'error'

      }

      return netResponse

    }).catch( reject = > {
      console.log('結(jié)果發(fā)生錯誤')

      let netResponse = new NetResponse< T >()
      netResponse.code = reject.code
      netResponse.msg  = reject.message
      return netResponse

    }).finally( () = > {
       r.destroy()
    })

  }

}

export default HNet

export function Get(targetUrl: string) : MethodDecorator {

  return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) = > {
        //替換方法
        descriptor.value = () = > {
           let options = new NetParams()
           options.url = targetUrl
            return HNet.get(options)
        }
  }

}
export class WeiBo{
  ok: number
  http_code: number
  data: WeiBoDataObj
}

export class WeiBoDataObj{
  total_number: number
  interval: number
  remind_text: string
  page: number
  statuses: Array< WeiBoItem >
}

export class WeiBoItem{
  created_at: string
  id: string
  source: string
  textLength: number
}
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 移動開發(fā)
    +關(guān)注

    關(guān)注

    0

    文章

    52

    瀏覽量

    9846
  • 鴻蒙
    +關(guān)注

    關(guān)注

    57

    文章

    2393

    瀏覽量

    43084
  • HarmonyOS
    +關(guān)注

    關(guān)注

    79

    文章

    1983

    瀏覽量

    30618
  • OpenHarmony
    +關(guān)注

    關(guān)注

    25

    文章

    3749

    瀏覽量

    16639
  • 鴻蒙OS
    +關(guān)注

    關(guān)注

    0

    文章

    190

    瀏覽量

    4548
收藏 人收藏

    評論

    相關(guān)推薦

    鴻蒙開發(fā)實戰(zhàn):網(wǎng)絡(luò)請求庫【axios】

    [Axios]?,是一個基于 promise 的網(wǎng)絡(luò)請求庫,可以運行 node.js 和瀏覽器中。本庫基于[Axios]原庫v1.3.4版本進行適配,使其可以運行在 OpenHarmony,并沿用其現(xiàn)有用法和特性。
    的頭像 發(fā)表于 03-25 16:47 ?4054次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b>實戰(zhàn):<b class='flag-5'>網(wǎng)絡(luò)</b><b class='flag-5'>請求</b>庫【axios】

    鴻蒙OS開發(fā)實例:【工具類封裝-http請求

    ;@ohos.promptAction';** **封裝HTTP接口請求類,提供格式化的響應(yīng)信息輸出功能。 使用 DevEco Studio 3.1.1 Release 及以上版本,API 版本為 api 9 及以上
    的頭像 發(fā)表于 03-27 22:32 ?1467次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>OS</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>實例</b>:【工具類封裝-http<b class='flag-5'>請求</b>】

    鴻蒙OS應(yīng)用程序開發(fā)

    這份學(xué)習(xí)文檔主要是帶領(lǐng)大家在鴻蒙OS上學(xué)習(xí)開發(fā)一個應(yīng)用程序,主要知識點如下:1、U-Boot引導(dǎo)文件燒寫方式;2、內(nèi)核鏡像燒寫方式;3、鏡像運行。
    發(fā)表于 09-11 14:39

    鴻蒙JS開發(fā)接口請求loading怎么解決?

    鴻蒙JS開發(fā)接口請求loading?
    發(fā)表于 05-10 10:24

    鴻蒙應(yīng)用開發(fā)請求不到數(shù)據(jù)是為什么?

    鴻蒙應(yīng)用開發(fā)請求不到數(shù)據(jù)
    發(fā)表于 06-15 11:04

    鴻蒙 OS 應(yīng)用開發(fā)初體驗

    的操作系統(tǒng)平臺和開發(fā)框架。HarmonyOS 的目標(biāo)是實現(xiàn)跨設(shè)備的無縫協(xié)同和高性能。 DevEco Studio 對標(biāo) Android Studio,開發(fā)鴻蒙 OS 應(yīng)用的 IDE。
    發(fā)表于 11-02 19:38

    嵌入式系統(tǒng)設(shè)計與實例開發(fā)—ARM與uC/OS-Ⅱ

    嵌入式系統(tǒng)設(shè)計與實例開發(fā) ——ARM與uC/OS-Ⅱ
    發(fā)表于 11-08 17:32 ?0次下載

    華為鴻蒙OS 2.0帶來哪些智慧體驗?

    華為已經(jīng)定于12月16日在北京發(fā)布鴻蒙OS 2.0手機開發(fā)者Beta版本。這不僅是手機鴻蒙OS的首次亮相,同時也意味著手機
    的頭像 發(fā)表于 12-15 15:10 ?2121次閱讀

    鴻蒙OS 2.0手機開發(fā)者Beta版發(fā)布會在京舉辦

    三個月前,鴻蒙OS 2.0正式在華為開發(fā)者大會2020亮相。12月16日,鴻蒙OS 2.0手機開發(fā)
    的頭像 發(fā)表于 12-16 09:29 ?1.9w次閱讀

    華為發(fā)布鴻蒙OS Beta版

    昨天華為發(fā)布鴻蒙OS Beta版了?鴻蒙系統(tǒng)一直在按照既有步伐前進,現(xiàn)在華為發(fā)布鴻蒙OS Beta版,而且一些生態(tài)
    的頭像 發(fā)表于 12-17 08:41 ?2933次閱讀

    鴻蒙OS與Lite OS的區(qū)別是什么

    鴻蒙OS鴻蒙OS面向未來、面向全場景、分布式。在單設(shè)備系統(tǒng)能力基礎(chǔ)上,鴻蒙OS提出了基于同一套系
    的頭像 發(fā)表于 12-24 12:40 ?5111次閱讀

    鴻蒙os怎么升級

    6月2日,華為正式發(fā)布了鴻蒙armonyOS 2系統(tǒng),那么鴻蒙os如何升級?現(xiàn)將鴻蒙os升級方式告知如下。
    的頭像 發(fā)表于 06-08 16:26 ?2819次閱讀

    華為開發(fā)者大會2021鴻蒙os在哪場

    華為開發(fā)者大會2021將在10月22日-24日舉辦,地點為東莞松山湖,鴻蒙os 3.0或?qū)⑴c我們見面,那么華為開發(fā)者大會2021鴻蒙
    的頭像 發(fā)表于 10-22 15:24 ?1957次閱讀

    鴻蒙OS開發(fā)實戰(zhàn):【網(wǎng)絡(luò)管理HTTP數(shù)據(jù)請求

    應(yīng)用通過HTTP發(fā)起一個數(shù)據(jù)請求,支持常見的GET、POST、OPTIONS、HEAD、PUT、DELETE、TRACE、CONNECT方法。
    的頭像 發(fā)表于 04-01 16:31 ?778次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>OS</b><b class='flag-5'>開發(fā)</b>實戰(zhàn):【<b class='flag-5'>網(wǎng)絡(luò)</b>管理HTTP數(shù)據(jù)<b class='flag-5'>請求</b>】

    鴻蒙OS開發(fā)實例:【HarmonyHttpClient】網(wǎng)絡(luò)框架

    鴻蒙上使用的Http網(wǎng)絡(luò)框架,里面包含純Java實現(xiàn)的HttpNet,類似okhttp使用,支持同步和異步兩種請求方式;還有鴻蒙版retrofit,和Android版Retrofit相
    的頭像 發(fā)表于 04-12 16:58 ?901次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>OS</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>實例</b>:【HarmonyHttpClient】<b class='flag-5'>網(wǎng)絡(luò)</b>框架