ant-design-vue/components/_util/classNames.js

28 lines
662 B
JavaScript
Raw Normal View History

2020-08-31 08:53:19 +00:00
import { isArray, isString, isObject } from './util';
2020-08-31 09:16:16 +00:00
function classNames() {
let classes = [];
for (let i = 0; i < arguments.length; i++) {
const value = arguments[i];
if (!value) continue;
if (isString(value)) {
classes.push(value);
} else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
const inner = classNames(value[i]);
if (inner) {
classes.push(inner);
}
}
} else if (isObject(value)) {
for (const name in value) {
if (value[name]) {
classes.push(name);
}
2020-08-31 08:53:19 +00:00
}
}
}
2020-08-31 09:16:16 +00:00
return classes.join(' ');
2020-08-31 08:53:19 +00:00
}
export default classNames;