shu-c-view
Version:
rollup 打包vue组件库框架
42 lines (40 loc) • 1.24 kB
JavaScript
/**
* @desc 滚动组件-el-scrollbar
* 在使用时要设置外层容器高度。并且要设置el-scrollbar 的高度为100%
*/
import _set from 'lodash/set';
import _isArray from 'lodash/isArray';
import _isEmpty from 'lodash/isEmpty';
import _isNil from 'lodash/isNil';
import { devConsole } from '../helper/util.js';
const BaseScrollbar = {
name: 'BaseScrollbar',
inheritAttrs: false,
props: {
ctCls: {
type: String
}
},
render(h) {
const myClass = {};
if (!_isNil(this.ctCls)) {
_set(myClass, this.ctCls, this.ctCls);
}
return h('el-scrollbar', { style: { height: '100%' }, class: myClass }, [
h('template', { slot: 'default' }, [this.$slots.default])
]);
}
};
BaseScrollbar.install = function(Vue, ElComponents) {
// 用于按需加载的时候独立使用
devConsole('按需加载独立组件:' + BaseScrollbar.name);
if (_isArray(ElComponents) && !_isEmpty(ElComponents)) {
for (let i = 0; i < ElComponents.length; i++) {
if (ElComponents[i].name !== BaseScrollbar.name) {
Vue.use(ElComponents[i]);
}
}
}
Vue.component(BaseScrollbar.name, BaseScrollbar);
};
export { BaseScrollbar };