• zepto 的 css 方法 -- 待续


    链接

    获取样式: 

     getComputedStyle  什么是计算后的样式

     就是经过css样式组合 和 js操作后 的 最后的结果

    设置样式有三种方法:

     
    div.style.backgroundColor = "red"
     
    div.style.setProperty('background-color','green')

    div.style.cssText += ";background-color:red;";

    删除相应的样式


    div.style.removeProperty('background-color')

    如何转为驼峰

    'background-color'  -- >  backgroundColor

    var cameLize = function(str) {


            return str.replace(/-+(.)?/g, function(match, chr) {

          //chr 就是 (.)  也就是 c, 因为前面一定有一个 -

          // 先判断chr有没有, 以免后面报错

          // match 这里是整体匹配到了 -c , 但是最后只取了子项, 并转为大写后返回 , 所以 -c 会被替换成 C


                    return chr ? chr.toUpperCase() : "";

          
            });


    };

    关键正则理解

    '/aaABBcdefH1g3Ggg'.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2');
     
     $1是AB  $2是Bc 


    而不是  aaABBcdefH  和 g ,

     因为要先保证 整体能匹配, 在分配 $1 $2,

  • 相关阅读:
    联考20200801 T2 皮卡丘
    联考20200729 T2 划愤
    联考20200801 T1 林海的密码
    联考20200725 T2 Tree
    联考20200721 T1 s1mple
    联考20200730 T2 小B的环
    联考20200730 T1 小B的班级
    联考20200718 T1 因懒无名
    联考20200723 T1 数
    联考20200722 T1 集合划分
  • 原文地址:https://www.cnblogs.com/dhsz/p/6483874.html
Copyright © 2020-2023  润新知