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;
    }
  • 相关阅读:
    数学学习合集
    萌萌的网络流~~
    2014西安全国邀请赛
    好题、趣题、麻烦题
    单调栈与单调队列
    字符串习题
    计算几何
    summer 2014 校队训练 嗷嗷待补之题
    2014多校联合训练第一场(组队训练)
    summer 2014 Round 4 解题报告
  • 原文地址:https://www.cnblogs.com/drop-in-ocean/p/7509883.html
Copyright © 2011-2022 走看看