前段时间学习vue的时候做了一个music webapp;对遇到的兼容性问题做一个总结

特性/兼容性UCQQChromeWebViewQQ内建微信内建
filter:blur()不支持支持,但是卡顿
<input type='range'/>自定义样式不支持支持
animation不支持reverse,keyframe需要@-webkit前缀√,keyframe需要@-webkit前缀
flex只支持box-flex的老式写法只支持box-flex的老式写法

解决方案

filter

由于uc 和qq兼容性问题, 采用filter.blur() 实现播放器背景的模糊效果会出问题, 采用opacity代替。

input range

检测浏览器类型,如果是uc 和 qq 或者firefox,讲input range 设置为display: none;,使用一个div 模拟input range;

<!--进度条-->
        <div class="player-progress">
          <div style="flex: 2; box-flex: 2">{{currentTimeFormatted}}</div>
          <div :style="{
               flex: 10,
               display: BrowserType !== 'OK' ? 'none' : ''
             }">
            <input type="range" max="100" v-model="progressValue" class="progress"
                   :style="{
              background: linear-gradient(to right, currentColor ${progressValue}%, #fff ${progressValue}%, #fff),
              width: '100%'
              // uc 不支持input range
            }"
            >
          </div>
          <div class="progress"
               :style="{
              display: BrowserType !== 'OK' ? '' : 'none', background: linear-gradient(to right, currentColor ${progressValue}%, #fff ${progressValue}%, #fff),
              height: '1px',
              'box-flex': 10 // uc 和 qq只支持box-flex的老式写法
            }"
          ></div>
          <div style="flex: 2; box-flex: 2">{{intervalFormatted}}</div>
        </div>

animation

加上@-webkit 和 @-moz的前缀

flex

flex 在uc 和qq 效果一般, 采用-webkit-box 效果好一些

判断浏览器类型

var a = navigator.userAgent
//    alert(a)
if (a.match('UCBrowser')) {
  window.sessionStorage.setItem('BrowserType', 'UCBrowser')
} else if (a.match('Firefox')) {
  window.sessionStorage.setItem('BrowserType', 'Firefox')
} else if (a.match('QQBrowser')) {
  window.sessionStorage.setItem('BrowserType', 'QQBrowser')
} else {
  window.sessionStorage.setItem('BrowserType', 'OK')
}

移动端meta

refer to :https://www.zhihu.com/question/19819577
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection"content="telephone=no, email=no" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- 删除苹果默认的工具栏和菜单栏 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!-- 设置苹果工具栏颜色 -->
<meta name="format-detection" content="telphone=no, email=no" />
<!-- 忽略页面中的数字识别为电话,忽略email识别 -->
<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">
<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">