index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div :class="className">
  3. <Grid :border="false" :column-num="filteredIcons.length" v-if="filteredIcons.length">
  4. <template v-for="(item, index) in filteredIcons" :key="index">
  5. <GridItem :icon="item.icon" :text="item.text" :to="item.to" />
  6. </template>
  7. </Grid>
  8. </div>
  9. </template>
  10. <script lang="ts" setup>
  11. import { shallowReactive, PropType, computed } from 'vue'
  12. import { Grid, GridItem } from 'vant'
  13. const props = defineProps({
  14. query: {
  15. type: Object
  16. },
  17. routes: {
  18. type: Array as PropType<string[]>,
  19. default: () => ([])
  20. },
  21. inset: {
  22. type: Boolean,
  23. default: false
  24. }
  25. })
  26. const className = {
  27. 'app-iconbar': true,
  28. 'app-iconbar--inset': props.inset
  29. }
  30. const icons = shallowReactive([
  31. { icon: 'pending-payment', text: '充值', to: { name: 'wallet-deposit' } },
  32. { icon: 'paid', text: '提现', to: { name: 'wallet-withdraw' } },
  33. { icon: 'peer-pay', text: '划转', to: { name: 'wallet-transfer' } },
  34. { icon: 'chart-trending-o', text: '交易', to: { name: 'spot-goods-detail' } },
  35. { icon: 'setting-o', text: '设置', to: { name: 'setting' } },
  36. ])
  37. const filteredIcons = computed(() => icons.filter((e) => props.routes.includes(e.to.name)))
  38. </script>
  39. <style lang="less">
  40. @import './index.less';
  41. </style>