在自定义组件里的触摸事件,传参到引用组件的页面那里
< canvas canvas-id = "lineCanvas" disable-scroll = "true" class = "canvas" bindtouchmove = "moveHandlerBind" bindtouchstart = 'touchHandlerBind' bindtouchend = 'touchEndHandlerBind' ></ canvas > |
methods: { touchHandlerBind: function (e) { this .triggerEvent( 'touchHandlerBind' , e, { bubbles: true , composed: true }); }, moveHandlerBind: function (e) { this .triggerEvent( 'moveHandlerBind' , e, { bubbles: true , composed: true }); }, touchEndHandlerBind: function (e) { this .triggerEvent( 'touchEndHandlerBind' , e, { bubbles: true , composed: true }); } } |
引用组件的页面
</ scroeDetail > |
moveHandlerBind: function (e) { this .setData({ moveHandler: e.detail, //在手机上这样写是正常的,但是在电脑上,e就是触摸返回的数据 }) }, touchHandlerBind: function (e) { this .setData({ touchHandler: e.detail, }) }, touchEndHandlerBind: function (e) { this .setData({ touchEndHandler: e.detail, }) }, |
电脑上引用组件的页面接到的数据是有问题的,整个e都是触摸的数据
{ "type" : "touchmove" , "timeStamp" :7001.8150000000005, "target" :{ "id" : "" , "offsetLeft" :0, "offsetTop" :0, "dataset" :{}}, "touches" :[{ "identifier" :0, "x" :280, "y" :69}], "changedTouches" :[{ "identifier" :0, "x" :280, "y" :69}]} |
手机上就是正常的,接收到的数组在e.detail里面
感谢反馈。应该是之前版本有bug。
开发工具项目设置里基础库版本是多少呢?
1.9.0没问题
1.7.4