zoukankan      html  css  js  c++  java
  • 9 Utils

    1 设置document.title(兼容微信浏览器)

     1 setDocumentTitle(t){
     2       document.title = t;
     3       let i = document.createElement('iframe');
     4       i.src = 'https://app.img.kangfuzi.com/icon/favicon.ico';
     5       i.style.display = 'none';
     6       i.onload = function () {
     7           setTimeout(function () {
     8               i.parentNode.removeChild(i);
     9           }, 9);
    10       };
    11       document.body.appendChild(i);
    12   }

    2 获取css属性(兼容IE)

     1 getCss(curEle,attr){
     2       let val = null;
     3       let reg = null;
     4       if("getComputedStyle" in window){
     5           val = window.getComputedStyle(curEle,null)[attr];
     6       } else {   //ie6~8不支持上面属性
     7           if(attr === "opacity"){
     8               val = curEle.currentStyle["filter"];   
     9               reg = /^alpha(opacity=(d+(?:.d+)?))$/i;
    10               val = reg.test(val)?reg.exec(val)[1]/100:1;
    11           } else {
    12               val = curEle.currentStyle[attr];
    13           }
    14       }
    15       reg = /^(-?d+(.d)?)(px|pt|em|rem)?$/i;
    16       return reg.test(val)?parseFloat(val):val;
    17   }

     3 深Copy

      

    function extend( dest, ...sources ) {
        const obj = sources[ 0 ];
        for( let property in obj ) {
            if( obj.hasOwnProperty( property ) ) {
                dest[ property ] = obj[ property ];
            }
        }
        if( sources.length > 1 ) {
            return extend( dest, ...sources.splice( 1, sources.length - 1 ) );
        }
        return dest;
    }
  • 相关阅读:
    第6章 对列表应用样式和创建导航条
    第3章 可视化格式模型
    第2章 为样式找到应用目标
    精通CSS 第1章
    JavaScript作用域学习笔记
    getByClass()
    判断各种数据类型
    值类型和引用类型的区别
    [原]Docker部署SuperMap8.1.1
    Docker初步
  • 原文地址:https://www.cnblogs.com/drop-in-ocean/p/7509883.html
Copyright © 2011-2022 走看看