zoukankan      html  css  js  c++  java
  • 移动端rem适配

    1.index.html

     <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,
        user-scalable=no">
    

    2.main.js

    // rem 适配
    var falses = true;
    //----------------------------------
    const setHtmlFontSize = () => {
      const htmlDom = document.getElementsByTagName('html')[0];
      let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
      if (htmlWidth > 413 && htmlWidth<735) {
        htmlWidth = 414;
        console.log( htmlWidth);
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
      //小米8适配
      if (htmlWidth == 393 ) {
        htmlWidth = 393;
        console.log( htmlWidth);
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
    
      if (htmlWidth <= 375) {
        htmlWidth = 375;
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
      if (htmlWidth > 1000) {
        falses =false
    
      }
    
    };
    if (falses){
    window.onresize = setHtmlFontSize;
    setHtmlFontSize();
    
    }
    

    3. 查看当期机型屏幕尺寸

                const screenWidth = document.body.clientWidth
                const screenHeight = document.body.clientHeight
                alert(`当前设备的屏幕尺寸(宽 x 高):${screenWidth} x ${screenHeight}`)
    

    4.手机查看vue项目

    vue.config.js

     devServer: {
            host: '111.11.11.11', // ip
            port: 8081, // 设置端口号
            https: false, // https:{type:Boolean}
            open: false, //配置自动启动浏览器
            proxy: null  //设置代理
        },
    
  • 相关阅读:
    redis和memcache的区别
    c语言行编辑程序
    C语言栈的实现
    双向链表
    静态链表的合并
    静态链表的创建
    链表
    将非递减有序排列(L L1)归并为一个新的线性表L2 线性表L2中的元素仍按值非递减
    C语言合并两个集合(L,L1) 将L1中不在L中的元素插入到L线性表中
    oracle--JOB任务
  • 原文地址:https://www.cnblogs.com/ouyangkai/p/13686314.html
Copyright © 2011-2022 走看看