mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] bem utils (#2443)
This commit is contained in:
parent
de9c7ffe0a
commit
72c57663de
@ -22,24 +22,19 @@ const prefix = (name, mods) => {
|
||||
}
|
||||
|
||||
const ret = {};
|
||||
mods && Object.keys(mods).forEach(key => {
|
||||
ret[name + MODS + key] = mods[key];
|
||||
});
|
||||
mods &&
|
||||
Object.keys(mods).forEach(key => {
|
||||
ret[name + MODS + key] = mods[key];
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
b(el, mods) {
|
||||
const { name } = this.$options;
|
||||
|
||||
if (el && typeof el !== 'string') {
|
||||
mods = el;
|
||||
el = '';
|
||||
}
|
||||
el = join(name, el, ELEMENT);
|
||||
|
||||
return mods ? [el, prefix(el, mods)] : el;
|
||||
}
|
||||
export default name => (el, mods) => {
|
||||
if (el && typeof el !== 'string') {
|
||||
mods = el;
|
||||
el = '';
|
||||
}
|
||||
el = join(name, el, ELEMENT);
|
||||
|
||||
return mods ? [el, prefix(el, mods)] : el;
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
* Create a basic component with common options
|
||||
*/
|
||||
import '../locale';
|
||||
import bem from '../mixins/bem';
|
||||
import createBem from './bem';
|
||||
import i18n from '../mixins/i18n';
|
||||
import { isDef, camelize } from '.';
|
||||
|
||||
@ -36,9 +36,10 @@ export default function (sfc) {
|
||||
sfc.name = 'van-' + sfc.name;
|
||||
sfc.install = sfc.install || install;
|
||||
sfc.mixins = sfc.mixins || [];
|
||||
sfc.mixins.push(i18n, bem);
|
||||
sfc.mixins.push(i18n);
|
||||
sfc.methods = sfc.methods || {};
|
||||
sfc.methods.isDef = isDef;
|
||||
sfc.methods.b = createBem(sfc.name);
|
||||
sfc.props && defaultProps(sfc.props);
|
||||
|
||||
return sfc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user