vue 控制窗口禁止缩放,已解决

注意:不是浏览器窗口禁止缩放

1.vue框架中,index.html文件head标签中加上内容

css 复制代码
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <script>
      document.addEventListener('mousewheel', function (e) {
        e = e || window.event;
        if ((e.wheelDelta && event.ctrlKey) || e.detail) {
          event.preventDefault();
        }
      }, {
        capture: false,
        passive: false
      });
    </script>
    <style>
      html {
        -ms-content-zooming: none;
      }
    </style>

2.App.vue中加上

css 复制代码
  mounted() {
// 禁止双击缩放
    window.onload = function() {
      document.addEventListener('touchstart', function(event) {
        if (event.touches.length > 1) {
          event.preventDefault()
        }
      })
      document.addEventListener('gesturestart', function(event) {
        event.preventDefault()
      })
    }
  },

完活儿!

相关推荐
10年前端老司机8 分钟前
前端最强大的excel插件
前端·javascript·vue.js
kali-Myon21 分钟前
攻防世界[level7]-Web_php_wrong_nginx_config
前端·nginx·安全·php·web·ctf·攻防世界
小胖同学~41 分钟前
插入排序C语言版
java·javascript·算法
大鱼七成饱1 小时前
彻底搞懂 react 的 use client
前端·javascript·next.js
CUIYD_19891 小时前
Ajax 核心知识点全面总结
前端·ajax·okhttp
菜鸡上道2 小时前
HTTP 请求中的 `Content-Type` 类型详解及前后端示例(Vue + Spring Boot)
vue.js·spring boot·http
Eliauk__2 小时前
深入浅出聊聊跨域:它到底是个啥,怎么破?
前端·javascript·面试
行星飞行2 小时前
Review-Gate MCP,让你的 cursor request 次数翻 5 倍
前端
小磊哥er2 小时前
【前端AI实践】DeepSeek:开源大模型的使用让开发过程不再抓头发
前端·vue.js·ai编程
Vesper632 小时前
【Vue】Vue2/3全局属性配置全攻略
前端·javascript·vue.js