在react native中有这么几种日志:
在debug模式下,react native默认打印trace以上级别日志
在release模式下,react native默认打印error以上级别日志
如果想在release模式下,打印所有console日志,可以在AppDelegate.m中这么干:
1、引入RCTLog头文件
#import <React/RCTLog.h>
2、在application方法中调整日志级别
RCTSetLogThreshold(RCTLogLevelInfo - 1)
然后在mac系统下就可以通过console.app来过滤查看日志:
有了js console日志,调试生产包就方便很多了!