localStorage is not working on google chrome

后端 未结 4 426
予麋鹿
予麋鹿 2021-01-14 10:14

I am using browsers localStorage to store a value, but while using google chrome, when we refresh the page using window.location.reload(), lo

4条回答
  •  遥遥无期
    2021-01-14 10:35

    You need to use the correct API for Storage:

    window.localStorage.setItem('value1', 'true');
    

    What you're doing is setting a property on a variable which won't persist between page loads. Firefox is likely being too smart and recognizing that you want to actually save the value in the browser's local storage store.

提交回复
热议问题