Demo.vue 447 B

1234567891011121314151617181920212223
  1. <template>
  2. <h2>当前求和为:{{sum}}</h2>
  3. <button @click="sum++">点我+1</button>
  4. <hr>
  5. <h2>当前点击时鼠标的坐标为:x:{{point.x}},y:{{point.y}}</h2>
  6. </template>
  7. <script>
  8. import {ref} from 'vue'
  9. import usePoint from '../hooks/usePoint'
  10. export default {
  11. name: 'Demo',
  12. setup(){
  13. //数据
  14. let sum = ref(0)
  15. let point = usePoint()
  16. //返回一个对象(常用)
  17. return {sum,point}
  18. }
  19. }
  20. </script>