GlobalLayout.vue 940B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <div id="global-layout" class="global-wrapper">
  3. <Navbar />
  4. <component :is="layout"/>
  5. <footer><h1>Footer</h1></footer>
  6. </div>
  7. </template>
  8. <script>
  9. import 'jquery/dist/jquery.slim.min.js'
  10. import 'bootstrap/dist/css/bootstrap.min.css'
  11. import 'bootstrap/dist/js/bootstrap.bundle.min.js'
  12. import Navbar from '@theme/components/Navbar.vue'
  13. export default {
  14. components: {
  15. Navbar
  16. },
  17. computed: {
  18. layout () {
  19. if (this.$page.path) {
  20. if (this.$frontmatter.layout) {
  21. // 你也可以像默认的 globalLayout 一样首先检测 layout 是否存在
  22. return this.$frontmatter.layout
  23. }
  24. return 'Layout'
  25. }
  26. return 'NotFound'
  27. }
  28. },
  29. mounted () {
  30. window.addEventListener('scroll', this.$themeScroll.notify)
  31. }
  32. }
  33. </script>
  34. <style lang="scss">
  35. body {
  36. padding-top: 4.5rem;
  37. overflow-y: auto;
  38. }
  39. </style>