繁体   English   中英

无法让Chrome popup.js使用console.log

[英]Cannot get Chrome popup.js to use console.log

我在编写JS时大量使用console.log进行调试。 我正在尝试使用它来编写chrome扩展,但它无法正常工作。 这里有一些诡计吗?

popup.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <link type="text/css" rel="stylesheet" href="css/jquery-ui-1.10.0.custom.min.css" />
    <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.10.0.custom.min.js"></script>
    <script type="text/javascript" src="js/popup.js"></script>
</head>

<body style="width: 200px">
</body>

popup.js

console.log('test1');
$(document).ready(function() {
    console.log('test2');
});

这些都不会出现在JS调试器中。

我最初也有这个问题! 确保打开了正确的开发人员工具窗口...我的意思是,您可能已经打开了主页面的开发人员工具窗口而不是扩展程序页面(即popup.html)。

要打开用于检查弹出窗口的开发人员工具窗口,请右键单击弹出窗口,然后单击“检查元素”...这将打开正确的开发人员工具窗口。

我最初犯了这个愚蠢的错误并被卡住了.. :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM