我正在设计一个从用户那里获取电子邮件的Chrome扩展程序。
每次用户关闭浏览器时,电子邮件的值都会丢失。
我可以定义一个静态变量吗?
我需要一个不变的变量。
最佳答案
您可以将其保存到扩展存储https://developer.chrome.com/extensions/storage
// Save it using the Chrome extension storage API.
chrome.storage.sync.set({'value': theValue}, function() {
// Notify that we saved.
message('Settings saved');
});