vue移动端开发的前面预适配

在APP.vue里面设置这个

document.addEventListener('DOMContentLoaded',()=>{
  const html=document.querySelector('html')
  let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
  let fontSize=htmlWidth/10
  fontSize=fontSize>50?50:fontSize
  html.style.fontSize=fontSize+'px'
})

在index.html里面设置

    <meta name="viewport" content="width=device-width,initial-scale=1.0">

还有对css进行预先处理,有人已经写了那么我就直接放链接
https://blog.csdn.net/chaitong2204/article/details/87737339

发布了6 篇原创文章 · 获赞 4 · 访问量 387

猜你喜欢

转载自blog.csdn.net/qq_34169711/article/details/104205278