在实际开发中,我们禁止缩放的实现方式:

1.meta设置:

<meta name="viewport"  content="width=device-width,height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" /> ,user-scalabel=no或者user-scalabel=yes(yes是可以缩放,no或者0是不能缩放)

在ios10以上的系统中,并不支持meta标签,需要我们通过脚本实现:

window.addEventListener(
"touchmove",
function(event) {
if (event.scale !== 1) {
event.preventDefault();
}
},
{ passive: false }
);
注意:禁用双指缩放后,scroll事件需要重新绑定,滚动条的事件监听touchmove,touchstart,touchend;
 

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2021-11-28
  • 2021-07-09
  • 2021-08-06
  • 2021-12-20
  • 2022-01-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-07-16
相关资源
相似解决方案