cache.js 381 B

12345678910111213141516171819202122
  1. export default {
  2. storage(key, value){
  3. try{
  4. if(arguments.length == 1) {
  5. return uni.getStorageSync(key);
  6. }
  7. if(arguments.length > 1) {
  8. if(value === null){
  9. uni.removeStorageSync(key);
  10. } else {
  11. uni.setStorageSync(key, value);
  12. }
  13. }
  14. }catch(e){
  15. uni.showToast({
  16. icon:'none',
  17. title: '程序发生错误'
  18. });
  19. }
  20. }
  21. }