tabbar.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <!-- 使用得时候必须加上style 不然没有--colorxxxxx之类得变量 -->
  3. <view class="tabbar align-center">
  4. <view v-for="(item, index) in tabbarList" :key="index" @click="switchTabs(item)" class="tablist">
  5. <view class="column align-center justify-center" >
  6. <image :src="actindex==index?item.selectedIconPath:item.iconPath" class="w48 h48"></image>
  7. <text class="fs24 base-textcol" :class="actindex==index?'actcolor':'morecolor'">{{item.Text}}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: "tabbar",
  15. props: {
  16. actindex: {
  17. type: Number,
  18. default: 0
  19. }
  20. },
  21. data() {
  22. return {
  23. tabbarList: [],
  24. };
  25. },
  26. mounted() {
  27. this.themeicon()
  28. },
  29. methods: {
  30. switchTabs(item) {
  31. // 到时候要设置两个tabbar 但是一教育页面得隐藏掉 这里得页面不能配置到tabbar得list里面
  32. uni.navigateTo({
  33. url: item.url
  34. })
  35. },
  36. themeicon() {
  37. const theme = this.themes
  38. this.tabbarList = [{
  39. iconPath: '/static/manageTabIcon/training.png',
  40. selectedIconPath: '/static/manageTabIcon/training_on.png',
  41. Text: '企业理念',
  42. url: '/pages/enterprise/enterprise'
  43. },
  44. {
  45. iconPath: '/static/manageTabIcon/manage.png',
  46. selectedIconPath: '/static/manageTabIcon/manage_on.png',
  47. Text: '我的',
  48. url: '/pages/user/wxuser'
  49. },
  50. ]
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .tabbar {
  57. display: flex;
  58. position: fixed;
  59. bottom: 0;
  60. left: 0;
  61. right: 0;
  62. background-color: #fff;
  63. z-index: 1000;
  64. height: 120rpx;
  65. padding-bottom: 20rpx;
  66. }
  67. .tablist {
  68. width: 50%;
  69. }
  70. .morecolor{
  71. color: #626468;
  72. }
  73. .actcolor {
  74. color: #1773ff;
  75. }
  76. </style>