Popup.js 不适用于 Chrome 扩展

蟒蛇新手

目前我正在开发一个 chrome 扩展程序,并且使用 popup.html 我无法让 popup.js 工作

popup.html

<!DOCTYPE html>
<html>
  <head>
    <title>Title</title>
  </head>

  <body style="width: 15rem; height: 15rem">
    <div class="container-fluid" style="padding: 10px"> 
        <input id="url" />
        <button type="button" id="newDetails">Submit</button>
    </div>
    <script src="./popup.js"></script>
  </body>
</html>

popup.js

console.log("Hello")
let btn = document.getElementById("newDetails");
btn.onclick = function () {
  console.log("Clicked!");
};

我已经查看了很多问题/答案(例如thisthisthis),但没有一个能够解决我的问题。

先感谢您!

蟒蛇新手

解决!由吴昊在原帖的评论中回答。

需要检查弹出窗口的控制台与浏览器控制台。您可以通过右键单击扩展名并检查它来做到这一点。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章