HowAreYou Asked:2022-09-05 18:42:16 +0800 CST2022-09-05 18:42:16 +0800 CST 2022-09-05 18:42:16 +0800 CST JS l chrome.storage 的问题 772 chrome.storage.sync.set({["test"]:"okay"}) chrome.storage.sync.get(['test'], result => { console.log(result) }); 我最近开始学习js,遇到了一个问题。chrome.storage里面有个test变量,值ok,我只要把这个变量的值打印到控制台,也就是ok,如果你执行上面附上的代码,我们会得到如下——试了value,text方法,还是不行,不神奇。希望我能解决这个问题。先感谢您) javascript google-chrome 1 个回答 Voted Best Answer another_login 2022-09-05T18:49:26+08:002022-09-05T18:49:26+08:00 阅读文档https://developer.chrome.com/docs/extensions/reference/storage/#usage chrome.storage.sync.set({key: value}, function() { console.log('Value is set to ' + value); }); chrome.storage.sync.get(['key'], function(result) { console.log('Value currently is ' + result.key); });
阅读文档https://developer.chrome.com/docs/extensions/reference/storage/#usage