开发者中使用——控制台打印数据
控制台打印输出数据是开发中很常用的功能
一、系统打印方法
1.基础打印console.log
console.log('Failed to load the content. Cause: %{public}s','1',sysBarProps)
2.打印复杂数据结构
如果对象、数组层级较深,可使用 JSON.stringify() 格式化后输出,避免内容被省略:
console.info('cateNameArr',JSON.stringify(this.cateNameArr, null, 2));
打印数据如下,数组里面对象格式
二、使用打印组件
1.hilog,也是默认模块入口Ability中使用的
import { hilog } from '@kit.PerformanceAnalysisKit';hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');