LayaNative supports the use of LocalStorage, but there are format requirements. GetItem() and setItem() must be used to store and obtain values.
//Storage the specified key name and key value, string type.
LocalStorage.setItem("LayaBox","H5 engine!");
//Get the value of the specified key name.
LocalStorage.getItem("LayaBox");
//Storage the specified key name and key value, string type.
Laya.LocalStorage.setItem("LayaBox","H5 engine!");
//Get the value of the specified key name.
Laya.LocalStorage.getItem("LayaBox");
The usage of the following js syntax is supported by PC browsers or mobile terminals (browser naked running), but is not supported by LayaNative.
//Storage, not supported under LayaNative
localStorage.test = 100;
//Value, not supported under LayaNative
alert(localStorage.test);