App.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script>
  2. export default {
  3. onLaunch() {
  4. console.log('App Launch')
  5. },
  6. onShow() {
  7. // #ifdef H5
  8. if (sessionStorage.getItem('store')) {
  9. this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem(
  10. 'store'))));
  11. sessionStorage.setItem('store', ''); //重新置完清空session
  12. }
  13. if (sessionStorage.getItem('stores')) {
  14. this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem(
  15. 'stores'))));
  16. sessionStorage.setItem('stores', ''); //重新置完清空session
  17. }
  18. window.addEventListener('beforeunload', () => {
  19. sessionStorage.setItem('store', JSON.stringify(this.$store.state));
  20. });
  21. // #endif
  22. },
  23. onHide() {
  24. console.log('App Hide')
  25. }
  26. }
  27. </script>
  28. <style lang="scss">
  29. /*每个页面公共css */
  30. @import '@/uni_modules/uni-scss/index.scss';
  31. // 设置整个项目的背景色
  32. page {
  33. color: $uni-main-color;
  34. font-size: 28rpx;
  35. background: $uni-background-color;
  36. img {
  37. width: 100%;
  38. height: 100%;
  39. }
  40. }
  41. </style>