js常用功能技巧函数

//CSS复合样式转成JS驼峰式
function cssStyle2DomStyle(sName) {
    return sName.replace(/-w/g,function(match){
        return match[1].toUpperCase();
    })
}

//简易模板
function template(context,json){
    var str = document.querySelector(context).innerHTML;
    var re = /{{s*(w+)s*}}/g;
    return str.replace(re,function(match,key){
        return json[key];
    })  
}
原文地址:https://www.cnblogs.com/vsmart/p/9398804.html