提交 855315f3 编写于 作者: W wanganxp

补充event的id

上级 dd8e5867
...@@ -2,174 +2,105 @@ ...@@ -2,174 +2,105 @@
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
<!-- #endif --> <!-- #endif -->
<view> <page-head title="触摸方块测试相关事件"></page-head>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt container"> <view class="uni-padding-wrap uni-common-mt container">
<view <view class="target" @touchstart="onTouchStart" @touchcancel="onTouchCancel" @touchmove="onTouchMove"
class="target" @touchend="onTouchEnd" @tap="onTap" @click="onClick" @longpress="onLongPress"></view>
@touchstart="onTouchStart"
@touchcancel="onTouchCancel"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
@tap="onTap"
@click="onClick"
@longpress="onLongPress"
></view>
<view v-if="touchStartEvent !== null"> <view v-if="touchStartEvent !== null">
<text class="title1">touchStart Event: </text> <text class="title1">touchStart Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
<template <template v-for="(touch, index) in touchStartEvent!.touches" :key="index">
v-for="(touch, index) in touchStartEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
<text class="title2 uni-common-mt">changedTouches: </text> <text class="title2 uni-common-mt">changedTouches: </text>
<template <template v-for="(touch, index) in touchStartEvent!.changedTouches" :key="index">
v-for="(touch, index) in touchStartEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
</view> </view>
<view v-if="touchCancelEvent !== null"> <view v-if="touchCancelEvent !== null">
<text class="title1">touchCancel Event: </text> <text class="title1">touchCancel Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
<template <template v-for="(touch, index) in touchCancelEvent!.touches" :key="index">
v-for="(touch, index) in touchCancelEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
<text class="title2 uni-common-mt">changedTouches: </text> <text class="title2 uni-common-mt">changedTouches: </text>
<template <template v-for="(touch, index) in touchCancelEvent!.changedTouches" :key="index">
v-for="(touch, index) in touchCancelEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
</view> </view>
<view v-if="touchMoveEvent !== null"> <view v-if="touchMoveEvent !== null">
<text class="title1">touchMove Event: </text> <text class="title1">touchMove Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
<template <template v-for="(touch, index) in touchMoveEvent!.touches" :key="index">
v-for="(touch, index) in touchMoveEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
<text class="title2 uni-common-mt">changedTouches: </text> <text class="title2 uni-common-mt">changedTouches: </text>
<template <template v-for="(touch, index) in touchMoveEvent!.changedTouches" :key="index">
v-for="(touch, index) in touchMoveEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
</view> </view>
<view v-if="longPressEvent !== null"> <view v-if="longPressEvent !== null">
<text class="title1">longPress Event: </text> <text class="title1">longPress Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
<template <template v-if="longPressEvent!.touches.length > 0" v-for="(touch, index) in longPressEvent!.touches"
v-if="longPressEvent!.touches.length > 0" :key="index">
v-for="(touch, index) in longPressEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
<text class="title2 uni-common-mt">changedTouches: </text> <text class="title2 uni-common-mt">changedTouches: </text>
<template <template v-for="(touch, index) in longPressEvent!.changedTouches" :key="index">
v-for="(touch, index) in longPressEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
</view> </view>
<view v-if="touchEndEvent !== null"> <view v-if="touchEndEvent !== null">
<text class="title1">touchEnd Event: </text> <text class="title1">touchEnd Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
<template <template v-if="touchEndEvent!.touches.length > 0" v-for="(touch, index) in touchEndEvent!.touches"
v-if="touchEndEvent!.touches.length > 0" :key="index">
v-for="(touch, index) in touchEndEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
<text class="title2 uni-common-mt">changedTouches: </text> <text class="title2 uni-common-mt">changedTouches: </text>
<template <template v-for="(touch, index) in touchEndEvent!.changedTouches" :key="index">
v-for="(touch, index) in touchEndEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text> <text class="title3">touch[{{ index }}]:</text>
<text>identifier: {{touch.identifier}}</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text> <text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text <text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text <text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template> </template>
</view> </view>
<view v-if="tapEvent !== null"> <view v-if="tapEvent !== null">
...@@ -181,13 +112,12 @@ ...@@ -181,13 +112,12 @@
<text>x: {{ clickEvent!.x }}, y: {{ clickEvent!.y }}</text> <text>x: {{ clickEvent!.x }}, y: {{ clickEvent!.y }}</text>
</view> </view>
</view> </view>
</view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
</template> </template>
<script lang="uts"> <script lang="uts">
export default { export default {
data() { data() {
return { return {
title: 'general-event', title: 'general-event',
...@@ -207,64 +137,68 @@ export default { ...@@ -207,64 +137,68 @@ export default {
} }
}, },
methods: { methods: {
onTouchStart(e: TouchEvent){ onTouchStart(e : TouchEvent) {
this.touchStartEvent = e this.touchStartEvent = e
this.onTouchStartTime = Date.now() this.onTouchStartTime = Date.now()
console.log('onTouchStart') console.log('onTouchStart')
}, },
onTouchCancel(e: TouchEvent){ onTouchCancel(e : TouchEvent) {
this.touchCancelEvent = e this.touchCancelEvent = e
console.log('onTouchCancel') console.log('onTouchCancel')
}, },
onTouchMove(e: TouchEvent){ onTouchMove(e : TouchEvent) {
this.touchMoveEvent = e this.touchMoveEvent = e
this.onTouchMoveTime = Date.now() this.onTouchMoveTime = Date.now()
console.log('onTouchMove') console.log('onTouchMove')
}, },
onLongPress(e: TouchEvent){ onLongPress(e : TouchEvent) {
this.longPressEvent = e this.longPressEvent = e
this.onLongPressTime = Date.now() this.onLongPressTime = Date.now()
console.log('onLongPress') console.log('onLongPress')
}, },
onTouchEnd(e: TouchEvent){ onTouchEnd(e : TouchEvent) {
this.touchEndEvent = e this.touchEndEvent = e
this.onTouchEndTime = Date.now() this.onTouchEndTime = Date.now()
console.log('onTouchEnd') console.log('onTouchEnd')
}, },
onTap(e: MouseEvent){ onTap(e : MouseEvent) {
this.tapEvent = e this.tapEvent = e
this.onTapTime = Date.now() this.onTapTime = Date.now()
console.log('onTap') console.log('onTap')
}, },
onClick(e: MouseEvent){ onClick(e : MouseEvent) {
this.clickEvent = e this.clickEvent = e
this.onClickTime = Date.now() this.onClickTime = Date.now()
console.log('onClick') console.log('onClick')
}, },
}, },
} }
</script> </script>
<style> <style>
.container { .container {
padding-bottom: 1000px; padding-bottom: 10px;
} }
.target {
.target {
margin: 20px 0 0 50px; margin: 20px 0 0 50px;
width: 200px; width: 200px;
height: 100px; height: 100px;
background-color: aqua; background-color: aqua;
} }
.title1 {
.title1 {
margin-top: 15px; margin-top: 15px;
font-size: 20px; font-size: 20px;
} }
.title2 {
.title2 {
margin-top: 10px; margin-top: 10px;
font-size: 18px; font-size: 18px;
} }
.title3 {
.title3 {
margin-top: 5px; margin-top: 5px;
font-size: 16px; font-size: 16px;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册