以iphone6屏幕尺寸设计

默认设置的html字体大小

在css样式文件里

html{
    font-size: 100px;
}
在public/index.html 加入代码,实现对不同设备的展示适配
<script>
var
width = document.documentElement.clientWidth || document.body.clientWidth; var ratio = width / 375; var fontSize = 100 * ratio; document.getElementsByTagName('html')[0].style['font-size'] = fontSize + 'px';
</script>

html完整代码

<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>
    <script>
      var width = document.documentElement.clientWidth || document.body.clientWidth;
      var ratio = width / 375;
      var fontSize = 100 * ratio;
      document.getElementsByTagName('html')[0].style['font-size'] = fontSize + 'px';
    </script>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>