我希望我的页面在第二次重新加载页面并写出我保存在localStorage中的名称时记住我。我已经在网上搜索了,却找不到任何东西。我现在正在按角度工作。谢谢。
尝试:
// after when name is populated
localStorage.setItem('somethingUniqueName', this.name);
// when you want to read it
this.name = localStorage.getItem('somethingUniqueName');
您也可以使用非常相似的sessionStorage
,但localStorage
更永久。您可以研究sessionStorage
和localStorage
之间的差异。