当前位置:   article > 正文

uni小程序 uview 1.8.8自定义tabBar_uview 自定义tabbar

uview 自定义tabbar

官网;安装 | uView - 多平台快速开发的UI框架 - uni-app UI框架 (uviewui.com)

先创建一个components文件,里面放置TabBar-TabBar.vue

  1. <template>
  2. <view>
  3. <u-tabbar v-model="current" :list="list" :mid-button="true" @change="ChangBar"></u-tabbar>
  4. </view>
  5. <!-- <image src="../../static/icon/我的.png" mode=""></image> -->
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. list: [{
  12. "pagePath": "/pages/index/index",
  13. iconPath: "home",
  14. selectedIconPath: "home-fill",
  15. text: '首页',
  16. // count: 2,
  17. // isDot: true,
  18. customIcon: false,
  19. },
  20. // {
  21. // "pagePath": "pages/Projection/Projection",
  22. // iconPath: "photo",
  23. // selectedIconPath: "photo-fill",
  24. // text: '放映厅',
  25. // customIcon: false,
  26. // },
  27. {
  28. "pagePath": "/pages/Scancode/Scancode",
  29. iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
  30. selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
  31. text: '发布',
  32. midButton: true,
  33. customIcon: false,
  34. },
  35. // {
  36. // "pagePath": "pages/live/live",
  37. // iconPath: "play-right",
  38. // selectedIconPath: "play-right-fill",
  39. // text: '直播',
  40. // customIcon: false,
  41. // },
  42. {
  43. "pagePath": "/pages/mine/mine",
  44. "iconPath": "account",
  45. "selectedIconPath": "account-fill",
  46. "text": '我的',
  47. // "count": 23,
  48. "isDot": false,
  49. "customIcon": false,
  50. },
  51. ],
  52. current: 0
  53. }
  54. },
  55. methods: {
  56. ChangBar(e) {
  57. console.log(e,'0999')
  58. uni.switchTab({
  59. url: this.list[e].pagePath
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style>
  66. </style>

在mian.js引入

  1. // 挂载tabBar
  2. import tabBar from "components/Tabbar/Tabbar.vue"//引入我们自己定义的tabBar组件
  3. Vue.component('tab-bar', tabBar)//使用tabBar组件

在需要的页面使用组件

在pages里面配置tabBar

 

  1. "tabBar": {
  2. "color": "#7A7E83",
  3. "selectedColor": "#3cc51f",
  4. "borderStyle": "white",
  5. "backgroundColor": "#f4f5f7",
  6. // "custom": true,
  7. "list": [{
  8. "pagePath": "pages/index/index",
  9. // "iconPath": "static/icon/首页.png",
  10. // "selectedIconPath": "static/icon/首页 1.png",
  11. "text": "首页",
  12. "count": 2,
  13. "isDot": true,
  14. "customIcon": false
  15. },
  16. {
  17. "pagePath": "pages/Scancode/Scancode",
  18. "text": "扫码",
  19. "midButton": true,
  20. "customIcon": false
  21. },
  22. {
  23. "pagePath": "pages/mine/mine",
  24. "text": "我的",
  25. "isDot": false,
  26. "customIcon": false
  27. }
  28. ],
  29. "current": 0
  30. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/594893
推荐阅读
  

闽ICP备14008679号