App.vue 461 B

1234567891011121314151617181920212223
  1. <template>
  2. <h2>自定义hook函数</h2>
  3. <h2>x: {{ x }} ,y: {{ y }}</h2>
  4. </template>
  5. <script lang="ts">
  6. import { defineComponent } from "vue";
  7. import userMouse from "./hook/userMouse";
  8. export default defineComponent({
  9. //需求: 用户在页面中点击页面,把点击的位置和横纵坐标收集起来并且展示出来
  10. setup() {
  11. const { x, y } = userMouse();
  12. return {
  13. x,
  14. y,
  15. };
  16. },
  17. });
  18. </script>
  19. <style scoped>
  20. </style>