【发布时间】:2021-08-10 19:31:45
【问题描述】:
我想禁用 Flutter Web 的放大功能。我已经尝试过这些事情:-
1) 将以下代码添加到 index.html 文件中
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
但它给了我以下警告并且没有禁用缩放。
WARNING: found an existing <meta name="viewport"> tag. Flutter Web uses its own viewport configuration for better compatibility with Flutter. This tag will be replaced.
2) 在 index.html 的 body 标签中添加以下代码:-
<script>
document.addEventListener('wheel', function(e) {
e.ctrlKey && e.preventDefault();
}, {
passive: false,
});
</script>
它禁用了使用 ctrl 和鼠标滚动进行缩放,但禁用了使用 ctrl + 进行缩放和使用 ctrl - 进行缩小的缩放。
所以,你能告诉我如何在所有平台(即桌面、android 和 ios)中禁用我的网页的放大和缩小。
【问题讨论】:
标签: javascript html flutter zooming flutter-web