1234567891011121314151617181920212223 |
- <template>
- <h2>自定义hook函数</h2>
- <h2>x: {{ x }} ,y: {{ y }}</h2>
- </template>
- <script lang="ts">
- import { defineComponent } from "vue";
- import userMouse from "./hook/userMouse";
- export default defineComponent({
- //需求: 用户在页面中点击页面,把点击的位置和横纵坐标收集起来并且展示出来
- setup() {
- const { x, y } = userMouse();
- return {
- x,
- y,
- };
- },
- });
- </script>
- <style scoped>
- </style>
|