diff --git a/src/col/index.js b/src/col/index.js index c0897d4ee..a1ba02aab 100644 --- a/src/col/index.js +++ b/src/col/index.js @@ -16,25 +16,25 @@ export default createComponent({ }, setup(props, { slots }) { + const getStyle = (vm) => { + const { index } = vm; + const { spaces } = vm.parent || {}; + + if (spaces && spaces[index]) { + const { left, right } = spaces[index]; + return { + paddingLeft: left ? `${left}px` : null, + paddingRight: right ? `${right}px` : null, + }; + } + }; + return (vm) => { const { tag, span, offset } = props; - const getStyle = () => { - const { index } = vm; - const { spaces } = vm.parent || {}; - - if (spaces && spaces[index]) { - const { left, right } = spaces[index]; - return { - paddingLeft: left ? `${left}px` : null, - paddingRight: right ? `${right}px` : null, - }; - } - }; - return ( {slots.default?.()} diff --git a/src/row/index.js b/src/row/index.js index b111023df..a6065e103 100644 --- a/src/row/index.js +++ b/src/row/index.js @@ -20,17 +20,8 @@ export default createComponent({ }, }, - emits: ['click'], - computed: { - spaces() { - const gutter = Number(this.gutter); - - if (!gutter) { - return; - } - - const spaces = []; + groups() { const groups = [[]]; let totalSpan = 0; @@ -45,7 +36,19 @@ export default createComponent({ } }); - groups.forEach((group) => { + return groups; + }, + + spaces() { + const gutter = Number(this.gutter); + + if (!gutter) { + return; + } + + const spaces = []; + + this.groups.forEach((group) => { const averagePadding = (gutter * (group.length - 1)) / group.length; group.forEach((item, index) => { @@ -63,27 +66,22 @@ export default createComponent({ }, }, - methods: { - onClick(event) { - this.$emit('click', event); - }, - }, + setup(props, { slots }) { + return () => { + const { tag, type, align, justify } = props; + const flex = type === 'flex'; - render() { - const { align, justify } = this; - const flex = this.type === 'flex'; - - return ( - - {this.$slots.default?.()} - - ); + return ( + + {slots.default?.()} + + ); + }; }, });