且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Uncaught TypeError:无法读取chrome扩展中未定义的属性'local'

更新时间:2021-07-09 21:59:28

确保所有必要的权限storage,就你的情况而言。

Make sure that all necessary permissions have been declared in the manifest file. "storage", in your case.

一般来说,以下步骤应该可以解决Chrome显然未定义的问题API:

In general, the following steps should fix the problem of apparently undefined Chrome APIs:


  1. 阅读您正在使用的API的文档,并熟悉先决条件,通常是清单权限( eg chrome.storage #manifest ) 。 通过查看新增功能

  2. 检查脚本是否正确运行上下文。大多数API仅适用于扩展程序的过程。 ( chrome.storage API也可以在内容脚本中使用)

  3. 否则,请使用常用的调试技巧:错别字,变量阴影......

  1. Read the documentation of the API you're using and get yourself familiar with the prerequisites, usually manifest permissions (e.g. chrome.storage#manifest).
  2. Check if your (user's) Chrome version supports the API, by looking at What's new.
  3. Check if the script is running in the right context. Most APIs are only available to the extension's process. (the chrome.storage API can also be used in content script though)
  4. Otherwise, resort to your usual debugging skills: Typos, variable shadowing, ...