TODO: description
import { StorageService } from '@onebuy/util';
enum EStorage {
Role = 'role',
User = 'user',
}
const storage = new StorageService<EStorage>({
rootKey: 'onebuy'
});
storage.set(EStorage.Role, 'admin');
storage.get(EStorage.Role); // 'admin'
storage.set(EStorage.User, {
name: 'Lucy',
email: 'balabala@163.com'
});
storage.get(EStorage.User); // { name: 'Lucy', email: 'balabala@163.com' }
storage.remove(EStorage.User);
storage.get(EStorage.User); // undefined
<!-- 需要先导入 axios -->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js" type="text/javascript"></script>
<script src="onebuy-util@2.0.0.min.js" type="text/javascript"></script>