要實現微信小程序 在canvas畫布上划動,頁面禁止滑動,不僅要設置disable-scroll="true",還要要給canvas綁定一個觸摸事件才能生效。
<canvas canvas-id="myCanvas" class="myCanvas" disable-scroll="false" bindtouchstart="touchStart" bindtouchmove="touchMove" bindtouchend="touchEnd">
</canvas>
關於canvas觸摸事件,在canvas上一定要綁定三個觸摸事件,真機才能響應到畫布觸摸的event。bindtouchstart/bindtouchmove/bindtouchend,只綁定兩個或一個會導致真機獲取不到canvas上的觸摸事件。