微信小程序 在canvas画布上划动,如何阻止页面上下动?
发布于 5 年前 作者 nluo 8123 次浏览 来自 问答

大家好,请教一个问题,:

我在做一个用canvas画图的小程序,但我在画时,真机上(iphone x)页面总是跟着上下动,在开发者工具上调试确不会滑动,怎么解决呢?

知乎上也有人提过这个,尝试了下面解决方案,但还是不行:


1.start,move,end,3个方法都有绑定触摸事件

<canvas class="container" disable-scroll="true" bindtouchstart="start" bindtouchmove="move" bindtouchend="end"  canvas-id="canvas" > 

</canvas>


2.使用scroll-view为节点,加上一些属性配置

<scroll-view scroll-x="true" scroll-y="true" class="container"  bindtouchstart="start" bindtouchmove="move" bindtouchend="end" >

</scroll-view>


非常感谢你的回答!

4 回复

a.在canvas上设置disable-scroll属性,禁止canvas进行上下滑动,并且还要设置一个触摸事件才能生效

<canvas  disable-scroll="true"></canvas>

b.在当前页面的page页面中设置

"disableScroll":true

咋解决的?

回到顶部