index.vue 648 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <div
  3. class="home-card"
  4. :style="{ left: left / 80 + 'rem', top: top / 80 + 'rem' }"
  5. @click="handleClick"
  6. >
  7. <div class="home-card__tag">
  8. <span>{{ name }}</span>
  9. </div>
  10. </div>
  11. </template>
  12. <script lang="ts" setup>
  13. import { toRefs } from "vue";
  14. import "./index.scss";
  15. import { useRouter } from "vue-router";
  16. const props = defineProps<{
  17. id: number;
  18. name: string;
  19. left: number;
  20. top: number;
  21. }>();
  22. const { name, left, top, id } = toRefs(props);
  23. const router = useRouter();
  24. const handleClick = () => {
  25. router.push({
  26. name: "cloudMuseum",
  27. params: {
  28. id: id.value,
  29. },
  30. });
  31. };
  32. </script>