App.vue 870 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. window.addEventListener('beforeunload', () => {
  14. sessionStorage.setItem('store', JSON.stringify(this.$store.state));
  15. });
  16. // #endif
  17. // #ifdef MP-WEIXIN
  18. // #endif
  19. },
  20. onHide() {}
  21. }
  22. </script>
  23. <style lang="scss">
  24. /*每个页面公共css */
  25. @import '@/uni_modules/uni-scss/index.scss';
  26. // 设置整个项目的背景色
  27. page {
  28. color: $uni-main-color;
  29. font-size: 28rpx;
  30. background: $uni-background-color;
  31. img {
  32. width: 100%;
  33. height: 100%;
  34. }
  35. }
  36. </style>