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 deba3a6396d23276c8788d6788eeb8b170e2567f..9aca2b61ec964f435d58eb648bdac65879989ec4 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); + } ); - }); ```