You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Chrome Debugger API调用detach方法出现签名不匹配错误的原因?

Chrome debugger.detach调用报错原因及修复

报错的核心原因是chrome.debugger.detach方法的参数传错了。

根据Chrome扩展debugger API的定义,detach方法的正确签名为:

chrome.debugger.detach(
  target: debugger.Debuggee,
  callback?: function
)

它仅接受两个参数:第一个是调试目标对象target,第二个是可选的回调函数,不需要传入协议版本号。你在调用时额外传入了"1.2"作为第二个参数,这与方法的参数签名不匹配,因此触发了类型错误。

修正后的代码示例:

chrome.debugger.attach(target, "1.2")
chrome.debugger.sendCommand(target, "Input.insertText", { text: "test."  })
chrome.debugger.detach(target)

// 若需要处理脱离后的结果,可添加回调函数
// chrome.debugger.detach(target, () => {
//   console.log("已成功脱离调试目标")
// })

内容的提问来源于stack exchange,提问作者丶 Limeー来夢 丶

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 14:00:47