我怎么知道一个泛事件已经在 nativescript-vue 中结束了?
How do I know a pan-event has ended in nativescript-vue?
nativescript-vue 的文档提供的手势信息很少。它们可以像这样使用 <Button @pan="handler" />
,但我怎么知道,例如泛事件已经结束?
gestures is scattered, to date. But here is what I found: the event handler is passed an event object, as usual. This has a property called state
which is a number to be interpreted using the GestureStateTypes 枚举的文档。您可以确定 pan-event 是否已经结束:
import { GestureStateTypes } from 'tns-core-modules/ui/gestures';
export default {
methods: {
pan(event) {
if (event.state === GestureStateTypes.ended) {
console.log('Pan event has ended.');
}
},
},
}
这些都是可能的事件状态:began
、cancelled
、changed
、ended
。
nativescript-vue 的文档提供的手势信息很少。它们可以像这样使用 <Button @pan="handler" />
,但我怎么知道,例如泛事件已经结束?
gestures is scattered, to date. But here is what I found: the event handler is passed an event object, as usual. This has a property called state
which is a number to be interpreted using the GestureStateTypes 枚举的文档。您可以确定 pan-event 是否已经结束:
import { GestureStateTypes } from 'tns-core-modules/ui/gestures';
export default {
methods: {
pan(event) {
if (event.state === GestureStateTypes.ended) {
console.log('Pan event has ended.');
}
},
},
}
这些都是可能的事件状态:began
、cancelled
、changed
、ended
。