console.log() not working when I load my chrome ex

2019-01-09 14:14发布

问题:

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?

回答1:

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.