From 72668faa25b21cc9bf74e60540aefdc0106031bb Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 29 Jul 2020 17:13:29 +0800 Subject: [PATCH] perf: divider --- components/divider/index.jsx | 11 +++++------ examples/App.vue | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/divider/index.jsx b/components/divider/index.jsx index fb516afa8..dc5ca7963 100644 --- a/components/divider/index.jsx +++ b/components/divider/index.jsx @@ -1,6 +1,7 @@ import { inject } from 'vue'; import PropTypes from '../_util/vue-types'; import { ConfigConsumerProps } from '../config-provider'; +import { getSlot } from '../_util/props-util'; const Divider = { name: 'ADivider', @@ -16,23 +17,21 @@ const Divider = { }; }, render() { - const { prefixCls: customizePrefixCls, type, $slots, dashed, orientation = 'center' } = this; + const { prefixCls: customizePrefixCls, type, dashed, orientation = 'center' } = this; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('divider', customizePrefixCls); const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation; - + const children = getSlot(this); const classString = { [prefixCls]: true, [`${prefixCls}-${type}`]: true, - [`${prefixCls}-with-text${orientationPrefix}`]: $slots.default, + [`${prefixCls}-with-text${orientationPrefix}`]: children.length, [`${prefixCls}-dashed`]: !!dashed, }; return (