tabbar.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view class="tabbar">
  3. <view v-for="(item,index) in list" class="items" @click="changeMethods(item.id,index)">
  4. <u-image width="100%" height="60rpx" :src="index == showNavIndex ? item.selectedIconPath :item.iconPath"
  5. style="margin: auto;"></u-image>
  6. <view :class="{'actives':index == showNavIndex}">{{item.text}}</view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. /*
  12. * 自定义底部导航栏
  13. */
  14. export default {
  15. name: "tabbar",
  16. props: {
  17. // 配置参数
  18. list: {
  19. type: Array,
  20. default () {
  21. return []
  22. }
  23. },
  24. },
  25. data() {
  26. return {
  27. showNavIndex: 0,
  28. };
  29. },
  30. methods: {
  31. //底部导航选择操作
  32. changeMethods(id, index) {
  33. // console.log(id);
  34. this.showNavIndex = index;
  35. this.$emit('showIndex', id)
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss">
  41. .tabbar {
  42. background-color: #26272F;
  43. color: #FFFFFF;
  44. padding: 10px;
  45. position: fixed;
  46. bottom: 0px;
  47. width: 100%;
  48. text-align: center;
  49. }
  50. .items {
  51. margin: 1% 8%;
  52. float: left;
  53. }
  54. .actives {
  55. color: #18b566;
  56. }
  57. </style>