App.vue 828 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. console.log('App Launch')
  5. },
  6. // 在页面的onShow生命周期中
  7. onShow() {
  8. // 尝试从本地存储中恢复数据
  9. const savedState = uni.getStorageSync('vuex_state');
  10. if (savedState) {
  11. this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
  12. }
  13. },
  14. // 在页面的onHide生命周期中
  15. onHide() {
  16. // 保存状态到本地存储
  17. uni.setStorageSync('vuex_state', this.$store.state);
  18. }
  19. }
  20. </script>
  21. <style lang="scss">
  22. @import "@/static/scss/common.scss";
  23. @import "@/static/font/iconfont.css";
  24. // 设置整个项目的背景色
  25. page {
  26. color: $uni-main-color;
  27. font-size: 28rpx;
  28. background: $uni-background-color;
  29. .image {
  30. width: 100%;
  31. height: 100%;
  32. }
  33. }
  34. </style>