当我加载我的Chrome扩展时,console.log()不起作用 [英] console.log() not working when I load my chrome extension
问题描述
我正在关注创建Chrome扩展的基础知识
https://developer.chrome。 com / extensions / getstarted
我放置了一个console.log()语句,但它不会显示出来,我是否应该使用其他API在控制台上记录东西?
不,您应该在正确的地方寻找。 背景或活动页面的控制台和开发工具可通过开发者模式下的扩展列表访问 - there 将成为扩展列表下的链接。 p> 额外注意事项:活动页面的unloa d将会丢失日志。
额外说明:由于内容脚本在不同的上下文中执行,您需要选择控制台上方的上下文,如果您想在其中运行命令,而不是页面本身。 / p>
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?
No, you should be looking in the right place.
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屋!