跳至主内容
版本:0.82

console

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

警告

🚧 本页面正在完善中,请参考 MDN 文档 获取更多信息。

全局 console 对象,遵循 Web 规范定义。


方法

timeStamp()

tsx
console.timeStamp(
label: string,
start?: string | number,
end?: string | number,
trackName?: string,
trackGroup?: string,
color?: DevToolsColor
): void;

console.timeStamp API 允许你在性能面板时间线中添加自定义计时条目。

参数:

NameTypeRequiredDescription
labelstringYesThe label for the timing entry.
startstring | numberNo
  • If string, the name of a previously recorded timestamp with console.timeStamp.
  • If number, the DOMHighResTimeStamp. For example, from performance.now().
  • If undefined, the current time is used.
endstring | numberNo
  • If string, the name of a previously recorded timestamp with console.timeStamp.
  • If number, the DOMHighResTimeStamp. For example, from performance.now().
  • If undefined, the current time is used.
trackNamestringNoThe name of the custom track.
trackGroupstringNoThe name of the track group.
colorDevToolsColorNoThe color of the entry.
tsx
type DevToolsColor =
| 'primary'
| 'primary-light'
| 'primary-dark'
| 'secondary'
| 'secondary-light'
| 'secondary-dark'
| 'tertiary'
| 'tertiary-light'
| 'tertiary-dark'
| 'warning'
| 'error';