如何将localstorage项设置回null。 [英] How to set localstorage item back to null.
问题描述
我正在使用系统在用户发生重大更新时向用户发出警报,并且我使用LocalStorage执行此操作,当我制作系统时,我让系统检查tip是否为null,然后将当他们收到警报时提示为真。现在,我想将'tip'localstorage设置为null,并使用tip2代替。
我会这么做吗? localStorage.setItem('tip','null');
localStorage.setItem('tip','null')
如果您只是想将其设置为字符串null
I'm using a system to alert users when a major update has happened to a site, and I do it with LocalStorage, when I made the system, I made the system check if tip was "null", then set "tip" to true when they got the alert. Now, I would like to set the 'tip' localstorage back to null, and use "tip2" instead.
Would I do this? localStorage.setItem('tip', 'null');
localStorage.removeItem('tip')
if you are aiming to remove the key
localStorage.setItem('tip', 'null')
if you just want to set it to the string "null"
这篇关于如何将localstorage项设置回null。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!