AccountCard.vue 763 B

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <AccountCardMobile v-if="isGridLayout" :account="account" />
  3. <AccountCardDesktop v-else :account="account" />
  4. </template>
  5. <script setup lang="ts">
  6. import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
  7. import AccountCardMobile from './AccountCardMobile.vue';
  8. import AccountCardDesktop from './AccountCardDesktop.vue';
  9. const props = defineProps<{
  10. account: any;
  11. isGridLayout?: boolean;
  12. }>();
  13. // 检测是否为移动端
  14. const isMobile = ref(false);
  15. const checkIsMobile = () => {
  16. isMobile.value = window.innerWidth <= 1100;
  17. };
  18. onMounted(() => {
  19. checkIsMobile();
  20. window.addEventListener('resize', checkIsMobile);
  21. });
  22. onBeforeUnmount(() => {
  23. window.removeEventListener('resize', checkIsMobile);
  24. });
  25. </script>