Chrome devtools extension console

后端 未结 2 939
滥情空心
滥情空心 2021-02-14 10:22

I included this in my chrome extension manifest

\"devtools_page\": \"devtools.html\"

And in devtools.html I include a devtools.js file which c

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-14 10:53

    This message will be logged in the console of the developer tools. To view this console, detach the developer tools from the window, and press Ctrl + Shift + J.

    Here's an picture:

    1. Page (http://host/)
    2. + Devtools instance for http://host
    3.   + Devtools instance for chrome-devtools://devtools/devtools.html?... )
    

    Your message is currently logged to 3 (the console of the devtools instance) instead of 2 (the console of the page). To log the string to the page, use the chrome.experimental.devtools.console API.

    An alternative is to JSON-serialize your object, and use chrome.devtools.inspectedWindow.eval to log the result:

    var obj = ...;
    var str = JSON.stringify( obj );
    chrome.devtools.inspectedWindow.eval('console.log(' + str + ');');
    

提交回复
热议问题