返回

自动生成类插件

默认规则选项支持

完全自定义的匹配规则

一次性添加多条规则

如何使用newAutoClass.js

demo

if(newAutoClass) {
    newAutoClass.addRules({
        reg: , // 匹配正则
        solveFn: commonSolveFn // 处理函数
    })

    // 多参数
    newAutoClass.addRules({
        reg: , // 匹配正则
        solveFn: commonSolveFn // 处理函数
    },{
        reg: , // 匹配正则
        solveFn: commonSolveFn // 处理函数
    })

    // 链式操作
    newAutoClass.addRules({
        reg: , // 匹配正则
        solveFn: commonSolveFn // 处理函数
    }).addRules({
       reg: , // 匹配正则
       solveFn: commonSolveFn // 处理函数 
    })

    // 使用
    var autoClass = new newAutoClass(["width","height","margin","line-height","color","font-size"]);
    autoClass.run({
        unit = 'px',
        base = 1,
        log = true
    });
}

默认配置支持项

默认配置 举例 说明
width width-5 w-5.5
height height-5 h-5.5
padding pad-5 pad-t-5 pad-r-5 pad-b-5 pad-l-5
margin mar-5 mar-t-5 mar-r-5 mar-b-5 mar-l-5
font-size f-5 fz-5 font-size-5
line-height lh-5 line-height-5
color color-666666 color-333