我的Chrome扩展似乎没有以任何方式执行console.log。它跳过了。
console.log工作:我可以打开控制台,输入console.log('test');,它就可以工作了。它工作于其他脚本,即本地加载在HTML页面中的JS脚本,但不是从我的扩展中加载的。
我的background.js,我在下面的manifest.json中运行。它执行alert(),但不执行console.log
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, { file: "jquery-3.0.0.min.js" }, function() {
console.log('----');
alert('Hello!);
});
});我试过:
delete console.log,delete window.console和delete window[console]是Restoring console.log()和JavaScript console log in Magento的建议,但没有成功。background.js只包含一行-- console.log('----'); --仍然无法工作。我的manifest.json
{
"manifest_version": 2,
"name": "My Chrome Extension",
"description": "This extension will you save time.",
"version": "1.0",
"permissions": [
"http://*/*",
"https://*/*",
"tabs"
],
"browser_action": {
"name": "Click to start the extension"
},
"background": {
"scripts": ["background.js"]
}
}发布于 2016-06-30 14:11:11
扩展的控制台位于单独的window.You中,可以通过以下方式检查console.log()消息:
chrome://extension贷记:Where to read console messages from background.js in a Chrome extension?
https://stackoverflow.com/questions/38114077
复制相似问题