index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="page">
  3. <u-tabbar :value="tabbarValue" @change="name => tabbarValue = name" :fixed="true" :placeholder="true"
  4. :safeAreaInsetBottom="true" :border="false">
  5. <u-tabbar-item :text="item.text" v-for="(item,index) in list" :key="index" @click="changeTabbar">
  6. <image class="u-page__item__slot-icon" slot="active-icon" :src="item.activeImg"></image>
  7. <image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.inactiveImg"></image>
  8. </u-tabbar-item>
  9. </u-tabbar>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. tabbarIndex: 0
  16. },
  17. data() {
  18. return {
  19. tabbarValue: 0,
  20. list: [{
  21. activeImg: 'https://i.ringzle.com/file/20240106/57895bbc5414416ea5de2a537ed23dc3.png',
  22. inactiveImg: 'https://i.ringzle.com/file/20240106/29bd09ef7eb748f1820c335f86f74c61.png',
  23. text: '首页',
  24. path: '/pages/home/index'
  25. },
  26. {
  27. activeImg: 'https://i.ringzle.com/file/20240106/584d0a4108c44fa5bc566d0d0082e07d.png',
  28. inactiveImg: 'https://i.ringzle.com/file/20240106/9561cd3843694891998a34ed41be0ec8.png',
  29. text: '房态',
  30. path: '/pages/house/index'
  31. },
  32. {
  33. activeImg: 'https://i.ringzle.com/file/20240106/41a218ecacd543b28faf20760712c372.png',
  34. inactiveImg: 'https://i.ringzle.com/file/20240106/9873e71314e44c22aa880bec2ecdac85.png',
  35. text: '统计',
  36. path: '/pages/statistics/index'
  37. },
  38. {
  39. activeImg: 'https://i.ringzle.com/file/20240106/daf6362d4d6745c29501cf30a4d99bc2.png',
  40. inactiveImg: 'https://i.ringzle.com/file/20240106/8c1f9fc0b5604ef7b966d98f2ffb1d2e.png',
  41. text: '我的',
  42. path: '/pages/my/index'
  43. }
  44. ]
  45. }
  46. },
  47. mounted() {
  48. this.tabbarValue = this.tabbarIndex;
  49. },
  50. methods: {
  51. changeTabbar(e) {
  52. this.tabbarValue = e;
  53. uni.reLaunch({
  54. url: this.list[e].path
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="less">
  61. /deep/.u-page__item__slot-icon {
  62. width: 40rpx;
  63. height: 40rpx;
  64. margin: 8rpx 0 4rpx;
  65. }
  66. </style>
  67. <style lang="scss">
  68. </style>