WangShuXian6 / blog

FE-BLOG
https://wangshuxian6.github.io/blog/
MIT License
46 stars 10 forks source link

微信开发 WeChat #79

Open WangShuXian6 opened 5 years ago

WangShuXian6 commented 5 years ago

微信 bug

禁止微信下拉
document.addEventListener('touchmove', function (event) {
        event.preventDefault();
      });

视频自动播放

需要轻点事件 tab, click

<video class="video" preload="auto" :class="{hide:showTip || !showVideo}"
webkit-playsinline="true"
playsinline="true"
x5-playsinline=""
x-webkit-airplay="allow"
:poster="posterSrc"
ref="video"
controls
this.videEl = this.$refs.video;
this.videEl.play();

ios input 偏移
        <input type="text" @blur="blurPop" class="phone" v-model="phoneNumber" maxlength="11">
blurPop(){
      document.body.scrollTop = 0;
    }

//兼容所有浏览器设置scrollTop的方法:

    /**
     *获取scrollTop的值,兼容所有浏览器
     */
    function getScrollTop() {
      var scrollTop =
        document.documentElement.scrollTop ||
        window.pageYOffset ||
        document.body.scrollTop;
      return scrollTop;
    }

    /**
     *设置scrollTop的值,兼容所有浏览器
     */
    function setScrollTop(scroll_top) {
      document.documentElement.scrollTop = scroll_top;
      window.pageYOffset = scroll_top;
      document.body.scrollTop = scroll_top;
    }
WangShuXian6 commented 5 years ago

微信内置浏览器UserAgent的判断

function isWeixinBrowser(){
  return /micromessenger/.test(navigator.userAgent.toLowerCase())
}