From 3a6e2f9b2acb7e79972c17b7fe2e445b98279387 Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 13 Sep 2018 21:23:13 +0800 Subject: [PATCH] fix: add tabs listeners #189 --- components/tabs/tabs.jsx | 81 +++------------------------------ components/vc-tabs/src/Tabs.jsx | 5 +- 2 files changed, 8 insertions(+), 78 deletions(-) diff --git a/components/tabs/tabs.jsx b/components/tabs/tabs.jsx index 3bf96aa9a..7849c878e 100644 --- a/components/tabs/tabs.jsx +++ b/components/tabs/tabs.jsx @@ -86,10 +86,6 @@ export default { onPrevClick, onNextClick, animated, - destroyInactiveTabPane = false, - activeKey, - defaultActiveKey, - $slots, tabBarGutter, } = this const children = filterEmpty(this.$slots.default) @@ -181,80 +177,15 @@ export default { children: childrenWithClose.length > 0 ? childrenWithClose : children, __propsSymbol__: Symbol(), }, + on: { + ...this.$listeners, + change: this.handleChange, + }, + class: cls, } return ( - + ) - // const tabBarExtraContent = getComponentFromProp(this, 'tabBarExtraContent') - // const children = [] - // $slots.default && $slots.default.forEach((child) => { - // if (isEmptyElement(child)) { return } - // const { componentOptions } = child - // const __ANT_TAB_PANE = getSlotOptions(child).__ANT_TAB_PANE - // warning(__ANT_TAB_PANE, '`Tabs children just support TabPane') - // if (componentOptions && __ANT_TAB_PANE) { - // componentOptions.propsData = componentOptions.propsData || {} - // if (componentOptions.propsData.tab === undefined) { - // const tab = (componentOptions.children || []).filter(({ data = {}}) => data.slot === 'tab') - // componentOptions.propsData.tab = tab - // } - // children.push(child) - // } - // }) - // const tabBarProps = { - // props: { - // hideAdd, - // removeTab: this.removeTab, - // createNewTab: this.createNewTab, - // inkBarAnimated, - // tabBarGutter, - // }, - // on: { - // tabClick: onTabClick, - // prevClick: onPrevClick, - // nextClick: onNextClick, - // }, - // style: tabBarStyle, - // } - // const tabContentProps = { - // props: { - // animated: tabPaneAnimated, - // animatedWithMargin: true, - // }, - // } - // const tabsProps = { - // props: { - // prefixCls, - // tabBarPosition: tabPosition, - // tabBarProps: tabBarProps, - // tabContentProps: tabContentProps, - // destroyInactiveTabPane, - // defaultActiveKey, - // type, - // }, - // on: { - // change: this.handleChange, - // tabClick: this.onTabClick, - // }, - // } - // if (hasProp(this, 'activeKey')) { - // tabsProps.props.activeKey = activeKey - // } - // return ( - // - // {children} - // {tabBarExtraContent ? : null} - // - // ) }, } diff --git a/components/vc-tabs/src/Tabs.jsx b/components/vc-tabs/src/Tabs.jsx index eb040b5b8..92b50a2eb 100644 --- a/components/vc-tabs/src/Tabs.jsx +++ b/components/vc-tabs/src/Tabs.jsx @@ -1,3 +1,4 @@ +import omit from 'omit.js' import BaseMixin from '../../_util/BaseMixin' import PropTypes from '../../_util/vue-types' import KeyCode from './KeyCode' @@ -179,9 +180,7 @@ export default { contents.reverse() } return ( -
+
{contents}
)