fix(CellGroup): incorrect attrs

This commit is contained in:
chenjiahan 2020-08-24 19:47:52 +08:00
parent 53109895a9
commit 8f978addd4

View File

@ -1,10 +1,11 @@
// Utils
import { createNamespace } from '../utils';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('cell-group');
export default createComponent({
inheritAttrs: false,
props: {
title: String,
border: {
@ -13,19 +14,21 @@ export default createComponent({
},
},
setup(props, { slots }) {
return function () {
setup(props, { slots, attrs }) {
return () => {
const { title, border } = props;
const Group = (
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}>
<div class={[bem(), { [BORDER_TOP_BOTTOM]: border }]} {...attrs}>
{slots.default?.()}
</div>
);
if (props.title || slots.title) {
if (title || slots.title) {
return (
<>
<div class={bem('title')} {...this.$attrs}>
{slots.title ? slots.title() : props.title}
<div class={bem('title')}>
{slots.title ? slots.title() : title}
</div>
{Group}
</>