App.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div id="app">
  3. <!--导航栏-->
  4. <!-- <nav-bar v-if="type===1" />-->
  5. <!--下面的部分通过路由动态决定渲染与否-->
  6. <!--exclude,其值为正则,匹配到的组件的名称会被排除在keep-alive之外-->
  7. <keep-alive exclude="Collection,History">
  8. <router-view />
  9. </keep-alive>
  10. <!--页脚-->
  11. <!-- <footer-bar />-->
  12. <!--回到顶部按钮-->
  13. <!-- <el-backtop :visibility-height="100" :bottom="60" />-->
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'App',
  19. components: {
  20. },
  21. data() {
  22. return {
  23. type: 2
  24. }
  25. },
  26. created() {
  27. /**
  28. * 防止vuex中的state在界面刷新后丢失
  29. */
  30. // 在页面加载时读取sessionStorage里的状态信息
  31. if (sessionStorage.getItem('store')) {
  32. this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))))
  33. }
  34. // 在页面刷新时将vuex里的信息保存到sessionStorage里
  35. window.addEventListener('beforeunload', () => {
  36. sessionStorage.setItem('store', JSON.stringify(this.$store.state))
  37. })
  38. },
  39. methods: {
  40. }
  41. }
  42. </script>
  43. <style>
  44. @import "assets/css/base.css";
  45. #app {
  46. overflow-y: scroll;
  47. }
  48. .searchd {
  49. margin-top: 15px;
  50. text-align: center;
  51. }
  52. html,body,#app{
  53. height: 100%;
  54. width: 100%;
  55. }
  56. /*.fade-enter-active,.fade-leave-active {
  57. -webkit-transition:opacity 1s;
  58. transition:opacity 1s
  59. }
  60. .fade-enter,.fade-leave-to {
  61. opacity:0
  62. }*/
  63. </style>