zoukankan      html  css  js  c++  java
  • 在vue 中 使用 mint-ui 的 Picker 选择器 组件,在下滑或上滑和手机浏览器原生滑动事件有冲突(通常在 IOS 上 会有这个现象),可以监听 touchmove 事件,来阻止默认事件,具体看代码

    参考 http://iscrolljs.com/  这个网站

    代码如下:

    function isPassive () {
      var supportsPassiveOption = false
      try {
        addEventListener('test', null, Object.defineProperty({}, 'passive', {
          get: function () {
            supportsPassiveOption = true
          }
        }))
      } catch (e) {}
      return supportsPassiveOption
    }
    function preventDefaultFunc (e) {
      e.preventDefault()
    }
    export function preventTouchmove (onoff) {
      if (onoff) {
        document.body.addEventListener('touchmove', preventDefaultFunc, isPassive() ? {
          capture: false,
          passive: false
        } : false)
      } else {
        console.log('wawawwaawa')
        document.body.removeEventListener('touchmove', preventDefaultFunc, isPassive() ? {
          capture: false,
          passive: false
        } : false)
      }
    }

    然后通过 

    import { preventTouchmove } from 'utils/common'

    来导入这个方法,然后使用,onoff 是开关,来传 布尔值

    preventTouchmove(true/false)
  • 相关阅读:
    influxdb服务器 relay
    browse-agent type and curl post
    使用 Ansible 管理 MySQL 复制
    ansible里的item和with_items
    Ansible 从MySQL数据库添加或删除用户
    ansibel---tag模块
    ll | wc -l的陷阱
    ansible 判断和循环
    Ansible详解(二)
    Ansible详解(一)
  • 原文地址:https://www.cnblogs.com/suntao666/p/8628512.html
Copyright © 2011-2022 走看看