uniapp中H5端PC宽屏适配

一、创建pc.js文件

// #ifdef H5
(function () {
  var u = navigator.userAgent,
    w = window.innerWidth;
  if (!u.match(/AppleWebKit.*Mobile.*/) || u.indexOf("iPad") > -1) {
    window.innerWidth = 750 * (w / 1920);
    window.onload = function () {
      window.innerWidth = w;
    };
  }
})();
// #endif

二、App.vue添加适配样式

<style lang="scss">
/*  #ifdef  H5  */
body {
  max- 828rpx;  //最大宽度自己可以调整
  margin: auto !important;
}
/*  #endif  */
</style>

三、main.js中引入pc.js(要在导入app示例之前引入)

import Vue from "vue";
//导入PC适配JS(H5)
// #ifdef H5
import "./common/services/pc";
// #endif
import App from "./App";
原文地址:https://www.cnblogs.com/sttchengfei/p/15603157.html