加载 chrome 扩展时,console.log() 不起作用 [英] console.log() not working when I load my chrome extension
问题描述
我正在遵循创建 chrome 扩展程序的基础知识https://developer.chrome.com/extensions/getstarted我放置了一个 console.log() 语句,但它不会显示,我应该使用其他 API 在控制台上记录内容吗?
I am following the basics of creating a chrome extension https://developer.chrome.com/extensions/getstarted I placed a console.log() statement but it won't show up , should I be using some other API to log stuff on console?
推荐答案
不,你应该找对地方.
背景 或 事件页面 的控制台和开发工具可通过开发者模式下的扩展列表访问 - 有 将是扩展列表下的链接.
A background or event page's console and Dev Tools are accessible through the extension list in Developer mode - there will be a link under the extension listing.
额外注意:事件页面的卸载会丢失它的日志.
Extra note: event page's unload will lose the logs for it.
弹出页面的控制台和开发工具是可通过右键单击操作按钮 并选择检查弹出窗口"访问.
A popup page's console and Dev Tools are accessible through right-clicking the action's button and selecting "Inspect popup".
内容脚本的控制台和开发工具可通过正常访问用于执行内容脚本的页面的开发工具.
A content script's console and Dev Tools are accessible through the normal Dev Tools for the page that the content script executes in.
额外注意:由于内容脚本在不同的上下文中执行,如果您想在其中运行命令,您需要选择控制台上方的上下文,而不是页面本身.
Extra note: since a content script executes in a different context, you need to select that context above the console if you want to run commands in it, as opposed to the page itself.
这篇关于加载 chrome 扩展时,console.log() 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!