• 引入vue.js的html如何做到兼容pc和移动端?


    mounted: function () {
               let _this = this ;
               var str = window.navigator.userAgent;
                //  判断设备
                console.log(str,'---str')
              if(str.toLowerCase().indexOf("mobile") == -1){
                $(document).ready(function () {
                    _this.setSize() ;
                })
                // 窗口变化时
                $(window).resize( function () { _this.setSize()});
                this.dataTimePC = false ;
              }else{
                this.dataTimePC = true ;
              }
              this.upList();  // 数据请求
    
          },
    // methods
    
    setSize(){
                var whdef = 100/1920; // 表示1920的设计图,使用100PX的默认值
                var wH = window.innerHeight; // 当前窗口的高度
                var wW = window.innerWidth; // 当前窗口的宽度
                var rem = wW * whdef; // 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值
                console.log(rem,'rem---刷新')
                $( 'html' ).css( 'font-size' , rem + "px" );
            },

    作者:人参,每篇随笔皆原创(除非注明原作者的随笔),欢迎指正!

  • 相关阅读:
    tool公用工具方法
    angular5.x 拦截器 switchMap
    angular5.x拦截器 给get post请求添加参数user_token
    flex布局 阮一峰
    json.stringify()和json.parse()
    年份月数天数
    打印字母塔
    打印形状
    打印九九乘法表
    C语言猜数字游戏
  • 原文地址:https://www.cnblogs.com/panax/p/14436899.html
Copyright © 2020-2023  润新知