chrome插件 - storage的使用

manifest.json

"permissions": [
    "storage"
]

popup.js

var data = {
    "url": "http://127.0.0.1"
};
chrome.storage.local.set({ "data": data }, function(){
    console.log("设置local值成功");
    console.log(data);
});
chrome.storage.local.get(["data"], function(result){
    alert(result["data"].url);
});
posted @ 2024-02-22 23:00  wstong  阅读(300)  评论(0编辑  收藏  举报