global-events-transform.uvue 824 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <view>
  3. <view @click="onclick"
  4. style="transform: rotate(180deg); background-color: brown;width: 100px; height: 100px; margin: 8px auto;"
  5. @longpress="onLongPress" id="event-transform"></view>
  6. </view>
  7. <text style="margin:0px auto;">点击上面view触发点击事件</text>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. clickTriger: false,
  14. longClickTriger: false
  15. }
  16. },
  17. methods: {
  18. onclick(event : UniPointerEvent) {
  19. this.clickTriger = true
  20. uni.showToast({
  21. title: "触发了点击事件"
  22. })
  23. },
  24. onLongPress(event : UniTouchEvent) {
  25. this.longClickTriger = true
  26. uni.showToast({
  27. title: "触发了长按事件"
  28. })
  29. }
  30. }
  31. }
  32. </script>
  33. <style>
  34. </style>