关于js的一些怪异问题的解决方式

1、安卓手机图片抖动:

-webkit-backface-visibility: hidden;

-webkit-perspective: 1000;

2、手机端无点击效果

-webkit-tap-highlight-color: transparent;

-webkit-touch-callout: none;

user-select: none;

3、js 乘法问题

$scope.shangzheng.toFixed(2) *$scope.shenzheng.toFixed(2)

4、版本检测

var initStyle = window.getComputedStyle(el);

if (initStyle.position === '-webkit-sticky' || initStyle.position === 'sticky') return;

还有 JS 的话 比如检测是否支持 fetch 就检测 if (window.fetch)

functiongetAndroidVersion(ua) {

varua = ua || navigator.userAgent;

varmatch = ua.toLowerCase().match(/android\s([0-9\.]*)/);

returnmatch ? match[1] :false;

};

getAndroidVersion();//"4.2.1"

parseInt(getAndroidVersion());//4

parseFloat(getAndroidVersion());//4.2

5、判断是否来自微信界面: /MicroMessenger/i.test(navigator.userAgent)

6、touch-action: manipulation; 长按不会被选中。

auto

当触控事件发生在元素上时,由浏览器来决定进行哪些操作,比如对viewport进行平滑、缩放等。

none

当触控事件发生在元素上时,不进行任何操作。

pan-x

如果当前元素最近的父元素可以横向滚动时,浏览器只允许在该父元素上进行横向滚动。

pan-y

如果当前元素最近的父元素可以纵向滚动时,浏览器只允许在该父元素上进行纵向滚动。

manipulation

浏览器只允许进行滚动和持续缩放操作。任何其它被auto值支持的行为不被支持。

你可能感兴趣的:(关于js的一些怪异问题的解决方式)