如果需要禁止页面的缩放,需要在vue项目中做如下更改:
注:只设置meta,ios无效。
#index.html
<html lang="">
<head>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
...
</head>
...
</html>
# App.vue
<script>
window.onload = function() {
// 禁用双指放大
document.addEventListener('touchstart', function(event) {
if (event.touches.length > 1) {
event.preventDefault()
}
});
document.addEventListener('gesturestart', function(event) {
event.preventDefault()
})
// 禁用双击放大
var lastTouchEnd = 0;
document.documentElement.addEventListener('touchend', function (event) {
var now = Date.now();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, {
passive: false
});
};
</script>
最后
以上就是娇气火龙果最近收集整理的关于Vue项目中,如何禁止页面的缩放的全部内容,更多相关Vue项目中,如何禁止页面内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复