mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
feat: CellGroup component
This commit is contained in:
38
src-next/cell-group/index.js
Normal file
38
src-next/cell-group/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// Utils
|
||||
import { createNamespace } from '../utils';
|
||||
import { BORDER_TOP_BOTTOM } from '../utils/constant';
|
||||
|
||||
const [createComponent, bem] = createNamespace('cell-group');
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
title: String,
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { slots }) {
|
||||
return function () {
|
||||
const Group = (
|
||||
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}>
|
||||
{slots.default?.()}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (props.title || slots.title) {
|
||||
return (
|
||||
<>
|
||||
<div class={bem('title')} {...this.$attrs}>
|
||||
{slots.title ? slots.title() : props.title}
|
||||
</div>
|
||||
{Group}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return Group;
|
||||
};
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user