// Local storage setStorage (name, data) { let dataType = typeof data; // json对象 if(dataType === 'object'){ window.localStorage.setItem(name, JSON.stringify(data)); } // foundation type the else IF ([ 'Number', 'String', 'Boolean']. The indexOf (dataType)> = 0 ) { window.localStorage.setItem(name, data); } // Other types are not supported by the else { Alert ( 'local storage of this type can not be used' ); } } // remove the local store getStorage (name) { let data = window.localStorage.getItem(name); if(data){ return JSON.parse(data); } else{ return ''; } } // delete locally stored removeStorage (name) { window.localStorage.removeItem(name); }