javascript - 在运行教程中给出的代码后,按照 chrome 扩展教程得到“Uncaught SyntaxError:missing )”
问题描述
我一直在按照本教程在 Chrome 上进行扩展,但在我必须编写一个 JS 文件并编译它的步骤中遇到了困难。该代码已在教程中提供。
let changeColor = document.getElementById('changeColor');
chrome.storage.sync.get('color', function(data) {
changeColor.style.backgroundColor = data.color;
changeColor.setAttribute('value', data.color);
});
但是当我尝试重新加载扩展时,它给出了以下错误:
所以我查找了具有类似语法的chrome.storage API文档:
chrome.storage.sync.get(['key'], function(result) {
console.log('Value currently is ' + result.key);
});
我稍微修改了代码来调试它:
chrome.storage.sync.get(['color'], function(data) {
console.log('Value currently is ' + data.color);
});
我得到同样的错误:
有人可以解释我错过了什么吗?
解决方案
好的,所以我在 5 天后重新加载了程序,现在它以某种方式工作,不知道它是如何工作的。
推荐阅读
- git - 将两个 git 存储库与所有历史记录和所有分支合二为一
- swift - 如何在 SwiftUI 中追加到数组?
- ios - 快速错误:无法转换“UnsafeMutablePointer”类型的值
?到预期的参数类型'UnsafeMutablePointer ? - python - Python 3 偶尔会在换行符上拆分 argv
- python-3.x - 用两个自变量计算 numpy 数据的最有效方法
- c - 如何使用 MSYS2 和 Mingw-W64 使 GTK+ 3.0 信号处理程序在 Windows 10 上工作?
- mongodb - 数字 1 或 -1 在字符串字段的索引中意味着什么?
- arrays - 对象在 Datatable 中作为 React 子错误无效
- c++ - 如何从包含 qt 头文件中隐藏智能感知警告
- r - 如何根据大部分时间在哪里为新变量编码?