ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### `Window.innerWidth` > 浏览器视口(viewport)宽度(单位:像素),如果存在垂直滚动条则包括它。 #### 问题1:iphone在文档加载完成前后,`window.innerWidth`值不一样 ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no minimal-ui"> </head> <body> <div class="wrapper"> </div> <script> console.log(window.innerWidth); // iphone6s plus => 980 window.onload = function() { console.log(window.innerWidth); // iphone6s plus => 414 } </script> </body> </html> ``` 解决方法: ```html <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1, shrink-to-fit=no"> ``` * [关于shrink-to-fit](http://www.jianshu.com/p/d0d8d2195572)