From 42c545c41ab62182a887ec984289b9d5158a08df Mon Sep 17 00:00:00 2001 From: anyueling Date: Tue, 5 Jul 2022 19:10:28 +0800 Subject: [PATCH] =?UTF-8?q?request=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E6=A3=80=E6=B5=8B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anyueling --- .../reference/apis/js-apis-request.md | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index deba3a6396..9aca2b61ec 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -18,14 +18,16 @@ import request from '@ohos.request'; 默认支持https,如果要支持http,需要在config.json里增加network标签,属性标识 "cleartextTraffic": true。即: ``` +var config = { "deviceConfig": { "default": { "network": { - "cleartextTraffic": true + "cleartextTraffic":true } - ... + //... } } +} ``` @@ -466,11 +468,10 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo **示例:** ```js - downloadTask.on('progress', function download_callback(receivedSize, totalSize) { + downloadTask.on('progress', function download_callback(receivedSize, totalSize) { console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); } ); - }); ``` @@ -501,11 +502,10 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => **示例:** ```js - downloadTask .off('progress', function download_callback(receivedSize, totalSize) { - console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); - } + downloadTask .off('progress', function download_callback(receivedSize, totalSize) { + console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); + } ); - }); ``` @@ -529,11 +529,10 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void **示例:** ```js - downloadTask.on('complete', function callback() { - console.info('Download task completed.'); - } + downloadTask.on('complete', function callback() { + console.info('Download task completed.'); + } ); - }); ``` @@ -557,11 +556,10 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void **示例:** ```js - downloadTask.off('complete', function callback() { - console.info('Download task completed.'); - } + downloadTask.off('complete', function callback() { + console.info('Download task completed.'); + } ); - }); ``` @@ -591,11 +589,10 @@ on(type: 'fail', callback: (err: number) => void): void **示例:** ```js - downloadTask.on('fail', function callBack(err) { - console.info('Download task failed. Cause:' + err); - } + downloadTask.on('fail', function callBack(err) { + console.info('Download task failed. Cause:' + err); + } ); - }); ``` @@ -625,11 +622,10 @@ off(type: 'fail', callback?: (err: number) => void): void **示例:** ```js - downloadTask.off('fail', function callBack(err) { - console.info('Download task failed. Cause:' + err); - } + downloadTask.off('fail', function callBack(err) { + console.info('Download task failed. Cause:' + err); + } ); - }); ``` -- GitLab