赞
踩
- #width给的数据是基于设计稿给的宽度。
- <script>
- const WIDTH = 750
- const mobileAdapter = () => {
- let scale = screen.width/WIDTH
- let content = `width=${WIDTH}, initial-scale=${scale}, maximum-scale=${scale}, minimum-scale=${scale}`
- let meta = document.querySelector('meta[name=viewport]')
- if(!meta) {
- meta = document.createElement('meta')
- meta.setAttribute('name', 'viewport')
- document.head.appendChild(meta)
- }
- meta.setAttribute('content', content)
- }
- mobileAdapter()
- window.onorientationchange = mobileAdapter
- </script>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。