From 804a4e0193e2678d7f7ac3048c1795673929e16f Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 24 Aug 2020 15:48:43 +0800 Subject: [PATCH] refactor(Col): use setup --- src/col/index.js | 54 +++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/col/index.js b/src/col/index.js index 36db2b39c..c0897d4ee 100644 --- a/src/col/index.js +++ b/src/col/index.js @@ -15,39 +15,31 @@ export default createComponent({ }, }, - emits: ['click'], + setup(props, { slots }) { + return (vm) => { + const { tag, span, offset } = props; - computed: { - style() { - const { index } = this; - const { spaces } = this.parent || {}; + 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, - }; - } - }, - }, + if (spaces && spaces[index]) { + const { left, right } = spaces[index]; + return { + paddingLeft: left ? `${left}px` : null, + paddingRight: right ? `${right}px` : null, + }; + } + }; - methods: { - onClick(event) { - this.$emit('click', event); - }, - }, - - render() { - const { span, offset } = this; - return ( - - {this.$slots.default?.()} - - ); + return ( + + {slots.default?.()} + + ); + }; }, });