index.vue 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="layout-container">
  3. <!-- 子路由出口 -->
  4. <router-view />
  5. <!-- 底部导航栏 -->
  6. <van-tabbar v-model="active" active-color="#000" inactive-color="#D9DEE4" >
  7. <van-tabbar-item
  8. v-for="item in tabbar"
  9. :key="item.path"
  10. :icon="item.icon"
  11. :to="item.path"
  12. >{{ item.text }}</van-tabbar-item>
  13. </van-tabbar>
  14. </div>
  15. </template>
  16. <script>
  17. import Vue from 'vue'
  18. import { Tabbar, TabbarItem } from 'vant'
  19. Vue.use(Tabbar)
  20. Vue.use(TabbarItem)
  21. export default {
  22. name: 'Layout',
  23. data() {
  24. return {
  25. active: 0,
  26. tabbar: [
  27. {
  28. path: '/Course',
  29. text: '培训通知',
  30. icon: 'home-o'
  31. },
  32. {
  33. path: '/StrongPhoto',
  34. text: '精彩集锦',
  35. icon: 'search'
  36. },
  37. {
  38. path: '/UserCenter',
  39. text: '个人中心',
  40. icon: 'volume-o'
  41. }
  42. ]
  43. }
  44. },
  45. created() {
  46. this.tabbar.map((item, idx) => {
  47. if (item.path === this.$route.path) {
  48. this.active = idx
  49. }
  50. })
  51. },
  52. methods: {
  53. goto(path) {
  54. this.$router.push(path)
  55. }
  56. },
  57. components: {}
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. </style>