vue项目禁止浏览器网页缩放

1.在app.vue加入代码

window.addEventListener(
  "mousewheel",
  function (event) {
    if (event.ctrlKey === true || event.metaKey) {
      event.preventDefault();
    }
  },
  { passive: false }
);

//firefox
window.addEventListener(
  "DOMMouseScroll",
  function (event) {
    if (event.ctrlKey === true || event.metaKey) {
      event.preventDefault();
    }
  },
  { passive: false }
);

2.重新运行

你可能感兴趣的:(vue,vue.js,javascript)