# 手势事件 手势表示由å•ä¸ªæˆ–多个事件识别的è¯ä¹‰åŠ¨ä½œï¼ˆä¾‹å¦‚:点击ã€æ‹–动和长按)。一个完整的手势也å¯èƒ½ç”±å¤šä¸ªäº‹ä»¶ç»„æˆï¼Œå¯¹åº”手势的生命周期。支æŒçš„事件有: **触摸** - touchstart:手指触摸动作开始。 - touchmove:手指触摸åŽç§»åŠ¨ã€‚ - touchcancel:手指触摸动作被打æ–,如æ¥ç”µæ醒ã€å¼¹çª—。 - touchend:手指触摸动作结æŸã€‚ **点击** click:用户快速轻敲å±å¹•ã€‚ **长按** longpress:用户在相åŒä½ç½®é•¿æ—¶é—´ä¿æŒä¸Žå±å¹•æŽ¥è§¦ã€‚ 具体的使用示例如下: ```html <!-- xxx.hml --> <div class="container"> <div class="text-container" onclick="click"> <text class="text-style">{{onClick}}</text> </div> <div class="text-container" ontouchstart="touchStart"> <text class="text-style">{{touchstart}}</text> </div> <div class="text-container" ontouchmove="touchMove"> <text class="text-style">{{touchmove}}</text> </div> <div class="text-container" ontouchend="touchEnd"> <text class="text-style">{{touchend}}</text> </div> <div class="text-container" ontouchcancel="touchCancel"> <text class="text-style">{{touchcancel}}</text> </div> <div class="text-container" onlongpress="longPress"> <text class="text-style">{{onLongPress}}</text> </div> </div> ``` ```css /* xxx.css */ .container { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; } .text-container { margin-top: 30px; flex-direction: column; width: 600px; height: 70px; background-color: #0000FF; } .text-style { width: 100%; line-height: 50px; text-align: center; font-size: 24px; color: #ffffff; } ``` ```js // xxx.js export default { data: { touchstart: 'touchstart', touchmove: 'touchmove', touchend: 'touchend', touchcancel: 'touchcancel', onClick: 'onclick', onLongPress: 'onlongpress', }, touchCancel: function (event) { this.touchcancel = 'canceled'; }, touchEnd: function(event) { this.touchend = 'ended'; }, touchMove: function(event) { this.touchmove = 'moved'; }, touchStart: function(event) { this.touchstart = 'touched'; }, longPress: function() { this.onLongPress = 'longpressed'; }, click: function() { this.onClick = 'clicked'; }, } ``` 