简体   繁体   English

firefox web分机如何存储用户数据

[英]How to store user data in firefox web extension

I want to store data (increasing everytime the extension is "triggered") in a json file to display it for the user.我想将数据(每次扩展被“触发”时增加)存储在 json 文件中以显示给用户。 I can't find a solution on how to add a json file where I can store and overwrite data.我找不到关于如何添加 json 文件的解决方案,我可以在其中存储和覆盖数据。

To store persistent data between between uses, you'll need to use the "storage" API which you can read about here .要在两次使用之间存储持久数据,您需要使用“存储”API,您可以在此处阅读相关信息。

Basically, you'll want to include the storage API in your manifest, then call it with methods like let gettingAllStorageItems = browser.storage.local.get(null);基本上,您需要在清单中包含存储 API,然后使用let gettingAllStorageItems = browser.storage.local.get(null);之类的方法调用它。 . . Here's an example. 这是一个例子。

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

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