引入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" );
        },

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

原文地址:https://www.cnblogs.com/panax/p/14436899.html