WebStorm console.log 点击跳转到源码

介绍了在WebStorm里让console.log点击跳转到源码的方法,需让log符合特定格式,即console.log();后跟上文件绝对路径和行号,如此控制台会显示可点击链接,点击能跳转对应文件和行号。

WebStorm console.log 点击跳转到源码

让 log 符合以下格式:

console.log(at ${filePath}:${line}:1);

at 空格 文件绝对路径 : 行号 :1

这样 控制台会显示一个可以点击的链接,点击后会跳转到对应的文件和行号。

不同的开发工具,console.log快捷输入方法有所不同: - **Hbuildx**:在右边输入 `{ "console.log": { "prefix": "log", "body": [ "console.log();" ], "triggerAssist": false, "description": "Log output to console twice" } }` [^1]。 - **Webstorm**:编辑器自带一个 console.log 的快捷方式,即 `.log` 然后按回车键即可 [^2]。 - **VSCode**: - **使用插件**:安装 VSCode 插件 javascript console utils,创建时,先选中要打印的东西,然后按 `Cmd/Ctrl + Shift + L`;删除时,按 `Cmd/Ctrl + Shift + D`。若按 `Cmd/Ctrl + Shift + L` 显示“性能录制已开始”,是被 AMD Radeon Software 的快捷键影响,可通过开始菜单找到 AMD Radeon Software,找到右上角设置按钮,找到热键中的切换性能记录,根据操作提示重置热键,按 `delete` 键取消热键设置 [^3]。 - **用户代码配置**: - **JavaScript**:打开 vscode 点击左上角的文件,找到首选项,点击用户代码配置,在顶部输入框种输入 javas,选择 JavaScript 选项,打开里面注释的代码,写入如下内容: ```json { // Place your snippets for javascript here. "Print to console": { "prefix": "clg", "body": [ "console.log(\"$1>>>\", $1);", "$2" ], "description": "Log output to console" } } ``` - **TypeScript**:若使用的是 ts,有的话直接打开,没有的话添加以下内容: ```json { // Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the // same ids are connected. // Example: "Print to console": { "prefix": "clog", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" } } ``` [^4][^5]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值