Browse Source

feat: update divider (#2357)

* feat: update divider

* chore: remove base import

* style: move up slot.default() judge
pull/2364/head^2
zkwolf 5 years ago committed by GitHub
parent
commit
0935262334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      components/divider/index.jsx
  2. 2
      examples/index.js

17
components/divider/index.jsx

@ -1,6 +1,6 @@
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
import Base from '../base';
const Divider = {
name: 'ADivider',
@ -10,8 +10,10 @@ const Divider = {
dashed: PropTypes.bool,
orientation: PropTypes.oneOf(['left', 'right', 'center']),
},
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
render() {
const { prefixCls: customizePrefixCls, type, $slots, dashed, orientation = 'center' } = this;
@ -28,16 +30,17 @@ const Divider = {
return (
<div class={classString} role="separator">
{$slots.default && <span class={`${prefixCls}-inner-text`}>{$slots.default}</span>}
{$slots.default && $slots.default() && (
<span class={`${prefixCls}-inner-text`}>{$slots.default()}</span>
)}
</div>
);
},
};
/* istanbul ignore next */
Divider.install = function(Vue) {
Vue.use(Base);
Vue.component(Divider.name, Divider);
Divider.install = function(app) {
app.component(Divider.name, Divider);
};
export default Divider;

2
examples/index.js

@ -5,6 +5,7 @@ import Button from 'ant-design-vue/button';
import Drawer from 'ant-design-vue/drawer';
import Affix from 'ant-design-vue/affix';
import Alert from 'ant-design-vue/alert';
import Divider from 'ant-design-vue/divider';
import ConfigProvider from 'ant-design-vue/config-provider';
import Spin from 'ant-design-vue/Spin';
import Empty from 'ant-design-vue/empty';
@ -16,6 +17,7 @@ createApp(App)
.use(Drawer)
.use(Affix)
.use(Alert)
.use(Divider)
.use(Spin)
.use(Empty)
.mount('#app');

Loading…
Cancel
Save