diff --git a/src/flexible.js b/src/flexible.js index 4e7c545..18cf752 100644 --- a/src/flexible.js +++ b/src/flexible.js @@ -31,9 +31,10 @@ } } + var isAndroid = win.navigator.appVersion.match(/android/gi); + var isIPhone = win.navigator.appVersion.match(/iphone/gi); + if (!dpr && !scale) { - var isAndroid = win.navigator.appVersion.match(/android/gi); - var isIPhone = win.navigator.appVersion.match(/iphone/gi); var devicePixelRatio = win.devicePixelRatio; if (isIPhone) { // iOS下,对于2和3的屏,用2倍的方案,其余的用1倍方案 @@ -55,7 +56,9 @@ if (!metaEl) { metaEl = doc.createElement('meta'); metaEl.setAttribute('name', 'viewport'); - metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no'); + metaEl.setAttribute('content', + isAndroid ? 'width=device-width, ' : '' + + 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no'); if (docEl.firstElementChild) { docEl.firstElementChild.appendChild(metaEl); } else { @@ -114,4 +117,4 @@ return val; } -})(window, window['lib'] || (window['lib'] = {})); \ No newline at end of file +})(window, window['lib'] || (window['lib'] = {}));