UNPKG

@antmjs/vantui

Version:

一套适用于Taro3及React的vantui组件库

38 lines (37 loc) 878 B
import _typeof from "@babel/runtime/helpers/typeof"; import * as array from './array'; import * as object from './object'; var PREFIX = 'van-'; function join(name, mods) { name = PREFIX + name; mods = mods.map(function (mod) { return name + '--' + mod; }); mods.unshift(name); return mods.join(' '); } function traversing(mods, conf) { if (!conf) { return; } // 加前缀 if (typeof conf === 'string' || typeof conf === 'number') { mods.push(conf); } else if (array.isArray(conf)) { // 加前缀 conf.forEach(function (item) { traversing(mods, item); }); } else if (_typeof(conf) === 'object') { // 加属性 object.keys(conf).forEach(function (key) { conf[key] && mods.push(key); }); } } function _bem(name, conf) { var mods = []; traversing(mods, conf); return join(name, mods); } export { _bem };