diff --git a/zh-cn/1.diff b/zh-cn/1.diff deleted file mode 100644 index 35f417962db43d9be492250d8acbc119f9761485..0000000000000000000000000000000000000000 --- a/zh-cn/1.diff +++ /dev/null @@ -1,541 +0,0 @@ -diff --git a/zh-cn/application-dev/reference/apis/js-apis-logs.md b/zh-cn/application-dev/reference/apis/js-apis-logs.md -index 31dd38d1423d394442eafa6978746e051941944a..e13eb4bbbdf8c51c03bac40ef75d53dbf88480aa 100644 ---- a/zh-cn/application-dev/reference/apis/js-apis-logs.md -+++ b/zh-cn/application-dev/reference/apis/js-apis-logs.md -@@ -1,8 +1,6 @@ --# console (日志打印) -+# console 控制台 - --本模块提供基础的日志打印能力,支持按照日志级别打印日志信息。 -- --如果需要使用更高级的日志打印服务,比如按照指定标识筛选日志内容,推荐使用[`@ohos.hilog`](js-apis-hilog.md)。 -+本模块提供了一个简单的调试控制台,类似于浏览器提供的JavaScript控制台机制。 - - > **说明:** - > -@@ -10,9 +8,9 @@ - - ## console.debug - --debug(message: string): void -+debug(message: string, ...arguments: any[]): void - --打印debug级别的日志信息。 -+打印调试信息。可以传入多个参数,其中第一个用作主要消息,所有其他参数用作替换值。 - - **系统能力:** SystemCapability.ArkUI.ArkUI.Full - -@@ -21,13 +19,24 @@ debug(message: string): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | message | string | 是 | 表示要打印的文本信息。 | -+| arguments | any | 否 | 表示要打印的信息。 | - -+**示例:** -+```js -+const number = 5; -+console.debug('count: %d', number); -+// count: 5 -+console.debug('count:', number); -+// count: 5 -+console.debug('count:'); -+// count: -+``` - - ## console.log - --log(message: string): void -+log(message: string, ...arguments: any[]): void - --打印debug级别的日志信息。 -+打印日志信息。可以传入多个参数,其中第一个用作主要消息,所有其他参数用作替换值。用法同console.debug()。 - - **系统能力:** SystemCapability.ArkUI.ArkUI.Full - -@@ -36,13 +45,13 @@ log(message: string): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | message | string | 是 | 表示要打印的文本信息。 | -- -+| arguments | any | 否 | 表示要打印的信息。 | - - ## console.info - --info(message: string): void -+info(message: string, ...arguments: any[]): void - --打印info级别的日志信息。 -+打印日志信息(console.log()的别名)。可以传入多个参数,其中第一个用作主要消息,所有其他参数用作替换值。用法同console.debug()。 - - **系统能力:** SystemCapability.ArkUI.ArkUI.Full - -@@ -51,13 +60,13 @@ info(message: string): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | message | string | 是 | 表示要打印的文本信息。 | -- -+| arguments | any | 否 | 表示要打印的信息。 | - - ## console.warn - --warn(message: string): void -+warn(message: string, ...arguments: any[]): void - --打印warn级别的日志信息。 -+打印警告信息。可以传入多个参数,其中第一个用作主要消息,所有其他参数用作替换值。用法同console.debug()。 - - **系统能力:** SystemCapability.ArkUI.ArkUI.Full - -@@ -66,13 +75,13 @@ warn(message: string): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | message | string | 是 | 表示要打印的文本信息。 | -- -+| arguments | any | 否 | 表示要打印的信息。 | - - ## console.error - --error(message: string): void -+error(message: string, ...arguments: any[]): void - --打印error级别的日志信息。 -+打印错误信息。可以传入多个参数,其中第一个用作主要消息,所有其他参数用作替换值。用法同console.debug()。 - - **系统能力:** SystemCapability.ArkUI.ArkUI.Full - -@@ -81,30 +90,15 @@ error(message: string): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | message | string | 是 | 表示要打印的文本信息。 | -+| arguments | any | 否 | 表示要打印的信息。 | - - --**示例:** -- --``` --export default { -- clickConsole(){ -- var versionCode = 1; -- console.info('Hello World. The current version code is ' + versionCode); -- console.log(`versionCode: ${versionCode}`); -- // 以下写法从API Version 6开始支持console.log('versionCode:%d.', versionCode); -- } --} --``` -- --在DevEco Studio的底部,切换到“HiLog”窗口。选择当前的设备及进程,日志级别选择Info,搜索内容设置为“Hello World”。此时窗口仅显示符合条件的日志,效果如图所示: -- --![zh-cn_image_0000001200913929](figures/zh-cn_image_0000001200913929.png) -- - ## console.assert10+ - - assert(value?: Object, ...arguments: Object[]): void - --若value为假,打印后续内容。 -+若value为假(false)或者省略,则console.assert()打印"Assertion failed"这条消息。 -+如果 value 为真值(true),则什么也不会发生。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -112,15 +106,16 @@ assert(value?: Object, ...arguments: Object[]): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| value | Object | 否 | 值 | -+| value | Object | 否 | 语句结果值。省略则打印"Assertion failed"。| - | arguments | Object | 否 | 错误消息打印。 | - - **示例:** --``` -+```js - console.assert(true, 'does nothing'); -+console.assert(2 % 1 == 0, 'does nothing'); // 表达式结果值为true。 - - console.assert(false, 'console %s work', 'didn\'t'); --// Assertion console:ohos didn't work -+// Assertion failed: console didn't work - - console.assert(); - // Assertion failed -@@ -129,7 +124,7 @@ console.assert(); - - count(label?: string): void - --维护一个内部计数器, 并输出调用label的console.count()次数。默认值为'default'。 -+维护一个内部计数器, 调用时,打印此标签名以及对应的计数次数。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -137,10 +132,11 @@ count(label?: string): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| label | string | 否 | 计数器标签名。 | -+| label | string | 否 | 计数器标签名。默认值为'default'。| -+ - - **示例:** --``` -+```js - console.count() - // default: 1 - console.count('default') -@@ -150,7 +146,7 @@ console.count('abc') - console.count('xyz') - // xyz: 1 - console.count('abc') --abc: 2 -+// abc: 2 - console.count() - // default: 3 - ``` -@@ -159,7 +155,7 @@ console.count() - - countReset(label?: string): void - --清除label名的计数。默认值为'default'。 -+清除指定标签名的计数。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -167,10 +163,10 @@ countReset(label?: string): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| label | string | 否 | 计数器标签名。 | -+| label | string | 否 | 计数器标签名。默认值为'default'。| - - **示例:** --``` -+```js - console.count('abc'); - // abc: 1 - console.countReset('abc'); -@@ -190,13 +186,25 @@ dir(dir?: Object): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| dir | Object | 否 | 需要打印内容的对象。 | -+| dir | Object | 否 | 需要打印内容的对象。省略则无任何打印。| -+ -+ -+**示例:** -+```js -+let a = { foo: { bar: { baz: true } }}; -+console.dir(a); -+// Object: {"foo":{"bar":{"baz":true}}} -+ -+console.dir(); // 无打印 -+``` -+ - - ## console.dirxml10+ - - dirxml(...arguments: Object[]): void - - 此方法调用 console.log() 将接收到的参数传给它。此方法不会产生任何 XML 格式。 -+使用方法与console.log()一致。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -204,14 +212,14 @@ dirxml(...arguments: Object[]): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| arguments | Object | 否 | 要打印的信息。 | -+| arguments | Object | 是 | 要打印的信息。 | - - ## console.group10+ - - group(...arguments: Object[]): void - --将后续行的缩进增加 groupIndentation 长度的空格。 --如果提供需要打印的信息,首先先打印信息,没有额外的缩进。 -+默认将后续行的缩进增加一定长度的空格。 -+如果提供需要打印的信息,则首先打印信息,没有额外的缩进。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -220,11 +228,26 @@ group(...arguments: Object[]): void - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | - | arguments | Object | 否 | 要打印的信息。 | -+ -+**示例:** -+```js -+console.log("outter"); -+// outter -+console.group(); -+console.log("level 1"); -+// level 1 -+console.group("in level1"); -+// in level1 -+console.log("level 2"); -+// level 2 -+``` -+ -+ - ## console.groupCollapsed10+ - - groupCollapsed(...arguments: Object[]): void - --group的别名。 -+console.group()的别名。使用方法与console.group()一致。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -238,10 +261,24 @@ group的别名。 - - groupEnd(): void - --将后续行的缩进减少 groupIndentation 长度的空格。 -+将后续行的缩进减少一定长度的空格。 - - **系统能力:** SystemCapability.Utils.Lang - -+ -+**示例:** -+```js -+console.log("outter"); -+// outter -+console.group(); -+console.log("level 1"); -+// level 1 -+console.groupEnd(); -+console.log("outter"); -+// outter -+``` -+ -+ - ## console.table10+ - - table(tableData?: Object): void -@@ -254,10 +291,10 @@ table(tableData?: Object): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| tableData | Object | 否 | 要打印为表格形式的对象。 | -+| tableData | Object | 否 | 要打印为表格形式的对象。省略则无任何打印。 | - - **示例:** --``` -+```js - console.table([1, 2, 3]); - // ┌─────────┬────────┐ - // │ (index) │ Values │ -@@ -281,7 +318,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); - - time(label?: string): void - --启动可用于计算操作持续时间的计时器。默认值为'default'。可使用console.timeEnd()关闭计时器并打印结果。 -+启动可用于计算操作持续时间的计时器。可使用console.timeEnd()关闭计时器并打印结果。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -289,13 +326,13 @@ time(label?: string): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| label | string | 否 | 计时器标识。 | -+| label | string | 否 | 计时器标识。默认值为'default'。 | - - ## console.timeEnd10+ - - timeEnd(label?: string): void - --停止之前通过调用 console.time() 启动的计时器并将结果打印。默认值为'default'。 -+停止之前通过调用 console.time() 启动的计时器并将结果打印。 - - **系统能力:** SystemCapability.Utils.Lang - -@@ -303,10 +340,10 @@ timeEnd(label?: string): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| label | string | 否 | 计时器标识。 | -+| label | string | 否 | 计时器标识。默认值为'default' | - - **示例:** --``` -+```js - console.time('abc'); - console.timeEnd('abc'); - // abc: 225.438ms -@@ -324,14 +361,13 @@ timeLog(label?: string, ...arguments: Object[]): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| label | string | 否 | 计时器标识。 | -+| label | string | 否 | 计时器标识。默认值为'default' | - | arguments | Object | 否 | 需要打印的其他日志。 | - - **示例:** --``` -+```js - console.time('timer1'); --const value = aaa(); // 返回 17 --console.timeLog('timer1', value); -+console.timeLog('timer1', 17); - // timer1: 365.227ms 17 - console.timeEnd('timer1'); - // timer1: 513.22ms -@@ -349,10 +385,14 @@ trace(...arguments: Object[]): void - - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ----------- | --| arguments | Object | 否 | 需要打印的其他日志。 | -+| arguments | Object | 否 | 需要打印的其他日志。省略则仅打印堆栈信息。| - - **示例:** --``` -+```js - console.trace(); -+// Trace: -+ xxxxxxxxxx(当前堆栈信息) - console.trace("Show the trace"); -+// Trace: Show the trace -+ xxxxxxxxxx(当前堆栈信息) - ``` -\ No newline at end of file -diff --git a/zh-cn/application-dev/reference/apis/js-apis-timer.md b/zh-cn/application-dev/reference/apis/js-apis-timer.md -index ae0957a9b4978d69674f4a63fa0b861fc1a3a48b..f1a695eda78ec4f456c4cdb54524a95065ee19d0 100644 ---- a/zh-cn/application-dev/reference/apis/js-apis-timer.md -+++ b/zh-cn/application-dev/reference/apis/js-apis-timer.md -@@ -18,7 +18,7 @@ setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): num - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | --| handler | Function \| string | 是 | 定时器到期后执行函数。 | -+| handler | Function \| string | 是 | 定时器到期后执行函数。类型为string则不处理。 | - | delay | number | 否 | 延迟的毫秒数,函数的调用会在该延迟之后发生。如果省略该参数,delay取默认值0,意味着“马上”执行,或尽快执行。 | - | ...arguments | Array<any> | 否 | 附加参数,一旦定时器到期,它们会作为参数传递给handler。 | - -@@ -26,24 +26,24 @@ setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): num - - | 类型 | 说明 | - | -------- | -------- | --| number | timeout定时器的ID。 | -+| number | 该定时器的ID。 | - - **示例:** - - ```js -- export default { -- setTimeOut() { -- var timeoutID = setTimeout(function() { -- console.log('delay 1s'); -- }, 1000); -- } -- } -+ setTimeout(function() { -+ console.log('delay 1s'); -+ }, 1000); -+ -+ let timeoutID = setTimeout(function() { -+ console.log('delay 1s'); -+ }, 1000); - ``` - - - ## clearTimeout - --clearTimeout(timeoutID: number): void -+clearTimeout(timeoutID?: number): void - - 取消了先前通过调用setTimeout()建立的定时器。 - -@@ -53,19 +53,15 @@ clearTimeout(timeoutID: number): void - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | --| timeoutID | number | 是 | 要取消定时器的ID, 是由setTimeout()返回的。 | -+| timeoutID | number | 否 | 要取消定时器的ID, 是由setTimeout()返回的。如果省略该参数,则不处理。| - - **示例:** - -- ```js -- export default { -- clearTimeOut() { -- var timeoutID = setTimeout(function() { -- console.log('do after 1s delay.'); -- }, 1000); -- clearTimeout(timeoutID); -- } -- } -+ ```js -+ let timeoutID = setTimeout(function() { -+ console.log('do after 1s delay.'); -+ }, 1000); -+ clearTimeout(timeoutID); - ``` - - -@@ -81,32 +77,32 @@ setInterval(handler: Function | string, delay: number, ...arguments: any[]): num - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | --| handler | Function \| string | 是 | 要重复调用的函数。 | --| delay | number | 是 | 延迟的毫秒数(一秒等于1000毫秒),函数的调用会在该延迟之后发生。 | -+| handler | Function \| string | 是 | 要重复调用的函数。 类型为string则不处理。| -+| delay | number | 是 | 延迟的毫秒数,函数的调用会在该延迟之后发生。 | - | ...arguments | Array<any> | 否 | 附加参数,一旦定时器到期,他们会作为参数传递给handler。 | - - **返回值:** - - | 类型 | 说明 | - | -------- | -------- | --| number | intervalID重复定时器的ID。 | -+| number | 该定时器的ID。 | - - **示例:** - - ```js -- export default { -- setInterval() { -- var intervalID = setInterval(function() { -- console.log('do very 1s.'); -- }, 1000); -- } -- } -+ setInterval(function() { -+ console.log('do very 1s.'); -+ }, 1000); -+ -+ let intervalID = setInterval(function() { -+ console.log('do very 1s.'); -+ }, 1000); - ``` - - - ## clearInterval - --clearInterval(intervalID: number): void -+clearInterval(intervalID?: number): void - - 可取消先前通过setInterval()设置的重复定时任务。 - -@@ -116,17 +112,13 @@ clearInterval(intervalID: number): void - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | --| intervalID | number | 是 | 要取消的重复定时器的ID,是由 setInterval() 返回的。 | -+| intervalID | number | 否 | 要取消的重复定时器的ID,是由 setInterval() 返回的。如果省略该参数,则不处理。| - - **示例:** - -- ```js -- export default { -- clearInterval() { -- var intervalID = setInterval(function() { -- console.log('do very 1s.'); -- }, 1000); -- clearInterval(intervalID); -- } -- } -+ ```js -+ let intervalID = setInterval(function() { -+ console.log('do very 1s.'); -+ }, 1000); -+ clearInterval(intervalID); - ``` - \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-logs.md b/zh-cn/application-dev/reference/apis/js-apis-console.md similarity index 76% rename from zh-cn/application-dev/reference/apis/js-apis-logs.md rename to zh-cn/application-dev/reference/apis/js-apis-console.md index f907d1d870c3355fbfa7724ea6949d8c5e9a6d41..913a633c9bbd8f1ed1d636d92ade41bdd272b9d1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-logs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-console.md @@ -36,7 +36,7 @@ console.debug('count:'); // 仅打印message log(message: string, ...arguments: any[]): void -以格式化输出方式打印日志信息。用法同console.debug()。 +以格式化输出方式打印日志信息。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -47,11 +47,22 @@ log(message: string, ...arguments: any[]): void | message | string | 是 | 表示要打印的文本信息。 | | arguments | any | 否 |表示其余要打印的信息或message的替换值。 | +**示例:** +```js +const number = 5; +console.log('count: %d', number); // 格式化输出替换message中的文本。 +// count: 5 +console.log('count:', number); // 打印message以及其余信息 +// count: 5 +console.log('count:'); // 仅打印message +// count: +``` + ## console.info info(message: string, ...arguments: any[]): void -以格式化输出方式打印日志信息。(console.log()的别名)。用法同console.debug()。 +以格式化输出方式打印日志信息。(console.log()的别名)。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -62,11 +73,22 @@ info(message: string, ...arguments: any[]): void | message | string | 是 | 表示要打印的文本信息。 | | arguments | any | 否 | 表示其余要打印的信息或message的替换值。 | +**示例:** +```js +const number = 5; +console.info('count: %d', number); // 格式化输出替换message中的文本。 +// count: 5 +console.info('count:', number); // 打印message以及其余信息 +// count: 5 +console.info('count:'); // 仅打印message +// count: +``` + ## console.warn warn(message: string, ...arguments: any[]): void -以格式化输出方式打印警告信息。用法同console.debug()。 +以格式化输出方式打印警告信息。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -74,14 +96,25 @@ warn(message: string, ...arguments: any[]): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ----------- | -| message | string | 是 | 表示要打印的文本信息。 | +| message | string | 是 | 表示要打印的警告信息。 | | arguments | any | 否 | 表示其余要打印的信息或message的替换值。 | +**示例:** +```js +const str = "name should be string"; +console.warn('warn: %d', str); // 格式化输出替换message中的文本。 +// warn: name should be string +console.warn('warn:', str); // 打印message以及其余信息 +// warn: name should be string +console.warn('warn:'); // 仅打印message +// warn: +``` + ## console.error error(message: string, ...arguments: any[]): void -以格式化输出方式打印错误信息。用法同console.debug()。 +以格式化输出方式打印错误信息。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full @@ -89,16 +122,26 @@ error(message: string, ...arguments: any[]): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ----------- | -| message | string | 是 | 表示要打印的文本信息。 | +| message | string | 是 | 表示要打印的错误信息。 | | arguments | any | 否 | 表示其余要打印的信息或message的替换值。 | +**示例:** +```js +const str = "value is not defined"; +console.error('error: %d', str); // 格式化输出替换message中的文本。 +// error: value is not defined +console.error('error:', str); // 打印message以及其余信息 +// error: value is not defined +console.error('error:'); // 仅打印message +// error: +``` + ## console.assert10+ assert(value?: Object, ...arguments: Object[]): void -若value为假(false)或者省略,则console.assert()打印"Assertion failed"这条消息。 -如果 value 为真值(true),则什么也不会发生。 +断言打印。 **系统能力:** SystemCapability.Utils.Lang @@ -106,13 +149,13 @@ assert(value?: Object, ...arguments: Object[]): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ----------- | -| value | Object | 否 | 语句结果值。省略则打印"Assertion failed"。| -| arguments | Object | 否 | 错误消息打印。 | +| value | Object | 否 | 语句结果值。若value为假(false)或者省略,则输出以"Assertion failed"开头。如果 value 为真值(true),则无打印。| +| arguments | Object | 否 | value为假(false)的后续错误消息打印。省略则不打印。| **示例:** ```js -console.assert(true, 'does nothing'); -console.assert(2 % 1 == 0, 'does nothing'); // 表达式结果值为true。 +console.assert(true, 'does nothing'); // 表达式结果值为true, 无打印。 +console.assert(2 % 1 == 0, 'does nothing'); // 表达式结果值为true, 无打印。 console.assert(false, 'console %s work', 'didn\'t'); // Assertion failed: console didn't work @@ -120,11 +163,12 @@ console.assert(false, 'console %s work', 'didn\'t'); console.assert(); // Assertion failed ``` + ## console.count10+ count(label?: string): void -维护一个内部计数器, 调用时,打印此标签名以及对应的计数次数。 +维护一个内部计数器,调用时,打印此标签名以及对应的计数次数。 **系统能力:** SystemCapability.Utils.Lang @@ -203,7 +247,7 @@ console.dir(); // 无打印 dirxml(...arguments: Object[]): void -此方法调用 console.log() 将接收到的参数传给它。此方法不会产生任何 XML 格式。qi'A使用方法与console.log()一致。 +此方法通过内部调用console.log()实现。此方法不会产生任何 XML 格式。使用方法与console.log()一致。 **系统能力:** SystemCapability.Utils.Lang @@ -213,6 +257,17 @@ dirxml(...arguments: Object[]): void | ------- | ------ | ---- | ----------- | | arguments | Object | 是 | 要打印的信息。 | +**示例:** +```js +const number = 5; +console.dirxml('count: %d', number); +// count: 5 +console.dirxml('count:', number); +// count: 5 +console.dirxml('count:'); +// count: +``` + ## console.group10+ group(...arguments: Object[]): void @@ -246,7 +301,7 @@ console.log("level 2"); groupCollapsed(...arguments: Object[]): void -console.group()的别名。使用方法与console.group()一致。 +使用与功能同console.group()一致。 **系统能力:** SystemCapability.Utils.Lang @@ -256,6 +311,20 @@ console.group()的别名。使用方法与console.group()一致。 | ------- | ------ | ---- | ----------- | | arguments | Object | 否 | 要打印的信息。| + +**示例:** +```js +console.groupCollapsed("outter"); +// outter +console.groupCollapsed(); +console.log("level 1"); +// level 1 +console.groupCollapsed("in level1"); +// in level1 +console.log("level 2"); +// level 2 +``` + ## console.groupEnd10+ groupEnd(): void @@ -317,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); time(label?: string): void -启动可用于计算操作持续时间的计时器。可使用console.timeEnd()关闭计时器并打印结果。 +启动可用于计算操作持续时间的计时器。可使用console.timeEnd()关闭计时器并打印经过的时间(单位:ms)。 **系统能力:** SystemCapability.Utils.Lang @@ -327,11 +396,16 @@ time(label?: string): void | ------- | ------ | ---- | ----------- | | label | string | 否 | 计时器标识。默认值为'default'。 | +**示例:** +```js +console.time('abc'); +``` + ## console.timeEnd10+ timeEnd(label?: string): void -停止之前通过调用 console.time() 启动的计时器并将结果打印。 +停止之前通过调用 console.time() 启动的计时器并将打印经过的时间(单位:ms)。 **系统能力:** SystemCapability.Utils.Lang @@ -352,7 +426,7 @@ console.timeEnd('abc'); timeLog(label?: string, ...arguments: Object[]): void -对于先前通过调用 console.time() 启动的计时器,打印经过时间和其他 data 参数。 +对于先前通过调用 console.time() 启动的计时器,打印经过时间和其他data参数。 **系统能力:** SystemCapability.Utils.Lang @@ -390,8 +464,8 @@ trace(...arguments: Object[]): void ```js console.trace(); // Trace: - xxxxxxxxxx(当前堆栈信息) +// xxxxxxxxxx(当前堆栈信息) console.trace("Show the trace"); // Trace: Show the trace - xxxxxxxxxx(当前堆栈信息) +// xxxxxxxxxx(当前堆栈信息) ``` \ No newline at end of file