App.vue 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <layout id="app">
  3. <template v-slot:main>
  4. <transition :name="transitionName" appear>
  5. <keep-alive :include="cashViews">
  6. <router-view class="router j-container" />
  7. </keep-alive>
  8. </transition>
  9. </template>
  10. </layout>
  11. </template>
  12. <script>
  13. import layout from '@/components/layout.vue'
  14. export default {
  15. name: 'App',
  16. components: {
  17. layout
  18. },
  19. computed: {
  20. transitionName () {
  21. return this.$store.state.direction
  22. }
  23. },
  24. data () {
  25. return {
  26. // 需要被缓存的组件,组件的name属性数组
  27. cashViews: ['home']
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss">
  33. #app {
  34. font-family: "Avenir", Helvetica, Arial, sans-serif;
  35. -webkit-font-smoothing: antialiased;
  36. -moz-osx-font-smoothing: grayscale;
  37. color: #2c3e50;
  38. width: 100%;
  39. height: 100%;
  40. position: relative;
  41. }
  42. .router {
  43. position: absolute;
  44. width: 100%;
  45. height: 100%;
  46. overflow-x: hidden;
  47. overflow-y: auto;
  48. }
  49. </style>