index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <demo-section>
  3. <demo-block :title="$t('basicUsage')">
  4. <van-tabbar v-model="active">
  5. <van-tabbar-item icon="home-o">{{ $t('tab') }}</van-tabbar-item>
  6. <van-tabbar-item
  7. icon="search"
  8. dot
  9. >
  10. {{ $t('tab') }}
  11. </van-tabbar-item>
  12. <van-tabbar-item
  13. icon="friends-o"
  14. info="5"
  15. >
  16. {{ $t('tab') }}
  17. </van-tabbar-item>
  18. <van-tabbar-item
  19. icon="setting-o"
  20. info="20"
  21. >
  22. {{ $t('tab') }}
  23. </van-tabbar-item>
  24. </van-tabbar>
  25. </demo-block>
  26. <demo-block :title="$t('customIcon')">
  27. <van-tabbar v-model="active2">
  28. <van-tabbar-item info="3">
  29. <span>{{ $t('custom') }}</span>
  30. <img
  31. slot="icon"
  32. slot-scope="props"
  33. :src="props.active ? icon.active : icon.normal"
  34. >
  35. </van-tabbar-item>
  36. <van-tabbar-item icon="search">{{ $t('tab') }}</van-tabbar-item>
  37. <van-tabbar-item icon="setting-o">{{ $t('tab') }}</van-tabbar-item>
  38. </van-tabbar>
  39. </demo-block>
  40. <demo-block :title="$t('customColor')">
  41. <van-tabbar
  42. v-model="active3"
  43. active-color="#07c160"
  44. >
  45. <van-tabbar-item icon="home-o">{{ $t('tab') }}</van-tabbar-item>
  46. <van-tabbar-item icon="search">{{ $t('tab') }}</van-tabbar-item>
  47. <van-tabbar-item icon="friends-o">{{ $t('tab') }}</van-tabbar-item>
  48. <van-tabbar-item icon="setting-o">{{ $t('tab') }}</van-tabbar-item>
  49. </van-tabbar>
  50. </demo-block>
  51. </demo-section>
  52. </template>
  53. <script>
  54. export default {
  55. i18n: {
  56. 'zh-CN': {
  57. customIcon: '自定义图标',
  58. customColor: '自定义颜色'
  59. },
  60. 'en-US': {
  61. customIcon: 'Custom icon',
  62. customColor: 'Custom Color'
  63. }
  64. },
  65. data() {
  66. return {
  67. active: 0,
  68. active2: 0,
  69. active3: 0,
  70. icon: {
  71. normal: 'https://img.yzcdn.cn/public_files/2017/10/13/c547715be149dd3faa817e4a948b40c4.png',
  72. active: 'https://img.yzcdn.cn/public_files/2017/10/13/793c77793db8641c4c325b7f25bf130d.png'
  73. }
  74. };
  75. }
  76. };
  77. </script>
  78. <style lang="less">
  79. .demo-tabbar {
  80. .van-tabbar {
  81. position: relative;
  82. &-item {
  83. cursor: pointer;
  84. }
  85. }
  86. }
  87. </style>