简体   繁体   English

如何更新本地存储值?

[英]how to update localstorage value?

Here is the origin json set in the local storage这里是在本地存储中设置的origin json

"profiles": [
    "headers":[
        "key": "val"
        "value": false
    ]
]

And I've got the value of the header which is false from the console by the following code我已经通过以下代码从控制台获得了 header 的值,这是错误

chrome.storage.local.get(['profiles'], function(p){console.log(p['profiles'][0]['headers'][0]['value'])})

Now I would like to update the header's value to true in this case现在我想在这种情况下将标头的值更新为true

I've tried both modified the value from get() callback and use the chrome.storage.local.set() But none of them are working.我已经尝试修改 get() 回调中的值并使用 chrome.storage.local.set() 但它们都没有工作。

Any suggestions how to do it?有什么建议怎么做吗?

Use利用

localStorage.setItem('key','value')

to update local storage.更新本地存储。

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

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