text: (window.webpackJsonp=window.webpackJsonp||[]).push([[59],{153:function(e,t,i){"use strict";i.r(t);var n=i(0),a=Object(n.a)({},function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"content"},[e._m(0),e._v(" "),e._m(1),e._v(" "),i("ul",[i("li",[e._v("在"),i("a",{attrs:{href:"https://caniuse.com/",target:"_blank",rel:"noopener noreferrer"}},[e._v("Can I Use"),i("OutboundLink")],1),e._v("网站查询兼容情况")]),e._v(" "),e._m(2),e._v(" "),i("li",[e._v("使用postcss做样式的后处理")])]),e._v(" "),e._m(3),e._v(" "),e._m(4),e._v(" "),e._m(5),e._v(" "),e._m(6),e._v(" "),e._m(7),e._v(" "),e._m(8),e._v(" "),e._m(9),e._v(" "),e._m(10),e._v(" "),e._m(11),e._v(" "),e._m(12),e._v(" "),e._m(13),e._v(" "),e._m(14),e._v(" "),e._m(15),e._v(" "),e._m(16),e._v(" "),e._m(17),e._v(" "),e._m(18),e._v(" "),e._m(19),e._v(" "),e._m(20),e._v(" "),e._m(21),e._v(" "),e._m(22),e._v(" "),e._m(23),e._v(" "),e._m(24),e._v(" "),e._m(25),e._v(" "),e._m(26),e._v(" "),e._m(27),e._v(" "),i("h3",{attrs:{id:"点击穿透问题"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#点击穿透问题","aria-hidden":"true"}},[e._v("#")]),e._v(" "),i("a",{attrs:{href:"http://www.fly63.com/article/detial/695",target:"_blank",rel:"noopener noreferrer"}},[e._v("点击穿透问题"),i("OutboundLink")],1)]),e._v(" "),e._m(28),e._v(" "),e._m(29),e._v(" "),e._m(30),e._v(" "),e._m(31),e._v(" "),e._m(32),e._v(" "),e._m(33),e._v(" "),e._m(34),e._v(" "),e._m(35),e._v(" "),e._m(36),e._v(" "),e._m(37),e._v(" "),e._m(38),e._v(" "),e._m(39),e._v(" "),e._m(40),e._v(" "),e._m(41),e._v(" "),e._m(42),e._v(" "),e._m(43),e._v(" "),e._m(44)])},[function(){var e=this.$createElement,t=this._self._c||e;return t("h1",{attrs:{id:"常见兼容问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#常见兼容问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 常见兼容问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("h2",{attrs:{id:"如何处理兼容问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#如何处理兼容问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 如何处理兼容问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("li",[this._v("在JS代码里使用对象检测，判断该特性是否支持 eg:\n"),t("ul",[t("li",[this._v("'XMLHttpRequest' in window")]),this._v(" "),t("li",[this._v("'WebkitMask' in document.documentElement.style")])])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h2",{attrs:{id:"样式问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#样式问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 样式问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"清除浏览器默认样式"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#清除浏览器默认样式","aria-hidden":"true"}},[this._v("#")]),this._v(" 清除浏览器默认样式")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("引入common.css或reset.css重置默认样式\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"清除ios输入框默认阴影"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#清除ios输入框默认阴影","aria-hidden":"true"}},[this._v("#")]),this._v(" 清除ios输入框默认阴影")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("-webkit-appearance: none;\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"清除ios触摸元素出现半透明灰色遮罩"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#清除ios触摸元素出现半透明灰色遮罩","aria-hidden":"true"}},[this._v("#")]),this._v(" 清除ios触摸元素出现半透明灰色遮罩")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v(" -webkit-tap-highlight-color: transparent;\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"ios滑动卡顿问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ios滑动卡顿问题","aria-hidden":"true"}},[this._v("#")]),this._v(" Ios滑动卡顿问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("body {-webkit-overflow-scrolling: touch; }\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"禁止复制、选中文本"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#禁止复制、选中文本","aria-hidden":"true"}},[this._v("#")]),this._v(" 禁止复制、选中文本")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("-webkit-user-select:none;\nuser-select:none;\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"修改input框的placehold样式"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#修改input框的placehold样式","aria-hidden":"true"}},[this._v("#")]),this._v(" 修改input框的placehold样式")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("input::-webkit-input-placeholder,\ntextarea::-webkit-input-placeholder {\n    color: #f00;\n}\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"模拟实现pc上的hover效果"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#模拟实现pc上的hover效果","aria-hidden":"true"}},[this._v("#")]),this._v(" 模拟实现PC上的hover效果")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("touchStart事件+touchEnd事件模拟\n在touchStart时添加class，在touchEnd时移除class\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"启用硬件加速"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#启用硬件加速","aria-hidden":"true"}},[this._v("#")]),this._v(" 启用硬件加速")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("-webkit-transform:translate3d(0,0,0)\ntransform: translate3d(0,0,0);\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"多倍屏1px像素问题和图片模糊问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#多倍屏1px像素问题和图片模糊问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 多倍屏1px像素问题和图片模糊问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("图片模糊使用多倍图，常使用2倍图做统一处理\n1px像素问题使用dpr查询和缩放解决（transfrom:scale(0.5/0.33)）\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"transition闪屏问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#transition闪屏问题","aria-hidden":"true"}},[this._v("#")]),this._v(" transition闪屏问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("/设置内嵌的元素在3D 空间如何呈现：保留3D /\n-webkit-transform-style: preserve-3d;\n/ 设置进行转换的元素的背面在面对用户时是否可见：隐藏 / \n-webkit-backface-visibility:hidden;\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"fixed定位问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#fixed定位问题","aria-hidden":"true"}},[this._v("#")]),this._v(" fixed定位问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("ios下fixed元素容易定位出错，软键盘弹出时，影响fixed元素定位，会以软键盘的上方为bottom:0;  \nandroid下fixed表现要比iOS更好，软键盘弹出时，不会影响fixed元素定位  \n解决：通过屏幕的resize事件重新给fixed元素设置样式\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"_300ms延迟问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#_300ms延迟问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 300ms延迟问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("浏览器如何判断快速点击时要区分单击事件和双击屏幕缩放的历史原因造成的，当用户在屏幕上单击某一个元素时候，  \n例如跳转链接<a href=\"#\"></a>，此处浏览器会先捕获该次单击，但浏览器不能决定用户是单纯要点击链接还是要双  \n击该部分区域进行缩放操作，所以，捕获第一次单击后，浏览器会先Hold一段时间t，如果在t时间区间里用户未进行  \n下一次点击，则浏览器会做单击跳转链接的处理，如果t时间里用户进行了第二次单击操作，则浏览器会禁止跳转，  \n转而进行对该部分区域页面的缩放操作。那么这个时间区间t有多少呢？在IOS safari下，大概为300毫秒。  这就是  \n延迟的由来。造成的后果用户纯粹单击页面，页面需要过一段时间才响应，给用户慢体验感觉，对于web开发者来说是，  \n页面js捕获click事件的回调函数处理，需要300ms后才生效，也就间接导致影响其他业务逻辑的处理。\n解决：fastclick库或者使用touchstart事件代替点击事件\nfastclick: \n    var FastClick = require('fastclick');\n    FastClick.attach(document.body);\ntouchstart事件：\n    触摸事件的响应顺序为 touchstart --\x3e touchmove --\x3e touchend --\x3e click,\n    也可以通过绑定ontouchstart事件，加快对事件的响应，解决300ms延迟问题\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("当A/B两个层上下z轴重叠，上层的A点击后消失或移开（这一点很重要），并且B元素本身有默认click事件（如a标签）或绑定了click事件。在这种情况下，点击A/B重叠的部分，就会出现点透的现象。\n本质原因: 事件触发顺序，参见上方\n解决：  fastclick库或者用touchend代替tap事件并阻止掉时A元素touchend的默认行为preventDefault()，从而阻止click事件的产生\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"js不执行问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#js不执行问题","aria-hidden":"true"}},[this._v("#")]),this._v(" js不执行问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("点击浏览器的回退，有时候不会自动执行js，特别是在mobilesafari中。这与往返缓存(bfcache)有关系。\n解决方法 ：window.onunload = function(){};\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"移动端audio-autoplay失效问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#移动端audio-autoplay失效问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 移动端audio autoplay失效问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("由于自动播放网页中的音频或视频，会给用户带来一些困扰或者不必要的流量消耗，所以苹果系统和安卓系统通常都会禁止自动播放和使用 JS 的触发播放，必须由用户来触发才可以播放\n解决方法思路：先通过用户 touchstart 触碰，触发播放并暂停\ndocument.addEventListener('touchstart',function() {\n    // 执行播放逻辑\n});\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h2",{attrs:{id:"移动端适配问题"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#移动端适配问题","aria-hidden":"true"}},[this._v("#")]),this._v(" 移动端适配问题")])},function(){var e=this.$createElement,t=this._self._c||e;return t("ul",[t("li",[this._v("navigator.useragent做环境检测和版本检测")]),this._v(" "),t("li",[this._v("媒体查询做宽高、屏幕比例和dpr的检测")]),this._v(" "),t("li",[this._v("Rem做布局单位")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"窗口适配，禁止用户缩放"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#窗口适配，禁止用户缩放","aria-hidden":"true"}},[this._v("#")]),this._v(" 窗口适配，禁止用户缩放")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v('<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />\n')])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"常用navigator-useragent"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#常用navigator-useragent","aria-hidden":"true"}},[this._v("#")]),this._v(" 常用navigator.useragent")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("const ua = navigator.userAgent.toLowerCase();\nlet UA = {};\nlet s = null;\nUA.ie = (s = ua.match(/(msie\\s|trident.*rv:)([\\d.]+)/)) ? s[2] : false;\nUA.firefox = (s = ua.match(/firefox\\/([\\d.]+)/)) ? !!s[1] : false;\nUA.chrome = (s = ua.match(/chrome\\/([\\d.]+)/)) ? !!s[1] : false;\nUA.opera = (s = ua.match(/opera.([\\d.]+)/)) ? !!s[1] : false;\nUA.safari = (s = ua.match(/version\\/([\\d.]+).*safari/)) ? !!s[1] : false;\nUA.android = (s = ua.match(/android/)) ? !!s : false;\nUA.iphone = (s = ua.match(/iphone os/)) ? !!s : false;\nUA.ipad = (s = ua.match(/ipad/)) ? !!s : false;\nUA.ios = UA.ipad || UA.iphone;\nUA.isWin32 = /win32/i.test(window.navigator.platform);\nUA.isWeixin = (s = ua.match(/MicroMessenger/i)) ? !!s : false; // 判断是否是在微信浏览器里面\nUA.isUcweb = (s = ua.match(/ucbrowser/)) ? !!s : false;\nUA.isMqq = navigator.userAgent.indexOf('QQ') !== -1;\nUA.isWeiBo = (s = ua.match(/__weibo__/)) ? !!s : false; // 是否微博浏览器\nUA.winClient = (s = ua.match(/winclient/)) ? !!s : false; // 是否pc客户端\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"rem计算"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#rem计算","aria-hidden":"true"}},[this._v("#")]),this._v(" rem计算")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("/**\n * 以750为基础做适配，1rem = 100px, 1rem = 100rpx;\n * 监听pc端的resize事件和mobile的横屏（orientationchange）事件\n */\nvar fun = function (doc, win) {\n  var docEl = doc.documentElement,\n      resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',\n      recalc = function () {\n          var clientWidth = docEl.clientWidth;\n          if (!clientWidth) return;\n\n          //这里是假设在750px宽度设计稿的情况下，1rem = 100px；\n          //可以根据实际需要修改\n          docEl.style.fontSize =  (clientWidth / 750)*100 + 'px';\n      };\n  if (!doc.addEventListener) return;\n  win.addEventListener(resizeEvt, recalc, false);\n  doc.addEventListener('DOMContentLoaded', recalc, false);\n}\nfun(document, window);\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"多倍屏处理"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#多倍屏处理","aria-hidden":"true"}},[this._v("#")]),this._v(" 多倍屏处理")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("通过媒体查询中的宽高和dpr做判断\n/* iphone 3 */\n@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 1) { }\n/* iphone 4 */\n@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 2) { }\n/* iphone 5 */\n@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (-webkit-device-pixel-ratio: 2) { }\n/* iphone 6, 6s */\n@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (-webkit-device-pixel-ratio: 2) { }\n/* iphone 7, 8 */\n@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (-webkit-device-pixel-ratio: 2) { }\n/* iphone 6+, 6s+, 7+, 8+ */\n@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (-webkit-device-pixel-ratio: 3) { }\n/* iphone X */\n@media only screen and (min-device-width: 375px) and (max-device-height: 812px) and (-webkit-device-pixel-ratio: 3) { }\n")])])},function(){var e=this.$createElement,t=this._self._c||e;return t("h3",{attrs:{id:"自适应处理"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#自适应处理","aria-hidden":"true"}},[this._v("#")]),this._v(" 自适应处理")])},function(){var e=this.$createElement,t=this._self._c||e;return t("pre",[t("code",[this._v("通过媒体查询 + 样式的覆盖\n/*小屏幕*/\n@media screen and (max-width: 768px) {}\n/*平板*/\n@media screen and (min-width: 768px) and (max-width: 992px){}\n/*中等屏幕*/\n@media screen and (min-width: 992px) and (max-width: 1200px){}\n/*大屏幕，或者宽屏*/\n@media screen and (min-width: 1200px) {}\n")])])}],!1,null,null,null);t.default=a.exports}}]);