App.vue 684 B

12345678910111213141516171819202122232425262728
  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) this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
  11. },
  12. // 在页面的onHide生命周期中
  13. onHide() {
  14. // 保存状态到本地存储
  15. uni.setStorageSync('vuex_state', this.$store.state);
  16. }
  17. }
  18. </script>
  19. <style lang="scss">
  20. /*每个页面公共css */
  21. @import '@/static/scss/common.scss';
  22. page {
  23. background-color: $uv-bg-color;
  24. font-size: 28rpx;
  25. }
  26. </style>