javascript - 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!");
};
我已经看过很多问题/答案(例如this、this、this),但没有一个能够解决我的问题。
先感谢您!
解决方案
解决!吴昊在原帖评论中回答。
需要检查弹出窗口的控制台与浏览器控制台。您可以通过右键单击扩展并检查它来做到这一点。
推荐阅读
- sql - 动态 Sp_Executesql 因日期时间转换错误而失败
- django - 如何创建一个查询集 order_by 并在此之后创建另一个订单来维护第一个订单的结果?
- html - 视频在 iPhone 上看起来不可见
- javascript - 如何在地图返回函数 ReactJS 中使用常量
- javascript - 从 JavaScript 中的用户代理信息获取设备名称
- go - Keep-alive:死节点检测
- arrays - 如何遍历具有不同类型的类数组并快速打印它们的属性?
- mongodb - 在 Julia 中使用 SSL 证书连接到 Mongodb
- python - 通过字符串调用函数
- jquery - 加载页面时如何加载模式