localStorage is not working on google chrome

后端 未结 4 425
予麋鹿
予麋鹿 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:47

    LocalStorage supports only string values, not boolean or others.

    Method to store and retrieve values:

    Put the value into storage

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

    Retrieve the value from storage

    var val1 = localStorage.getItem('value1');
    

    Read more on MDN..

提交回复
热议问题