Skip to content

feat: update divider #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions components/divider/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
import Base from '../base';
Expand All @@ -10,8 +11,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;
Expand All @@ -28,16 +31,18 @@ const Divider = {

return (
<div class={classString} role="separator">
{$slots.default && <span class={`${prefixCls}-inner-text`}>{$slots.default}</span>}
{$slots.default && (
<span class={`${prefixCls}-inner-text`}>{$slots.default && $slots.default()}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{$slots.default && $slots.default()} 前面判断一次了 直接 {$slots.default()}

)}
</div>
);
},
};

/* istanbul ignore next */
Divider.install = function(Vue) {
Vue.use(Base);
Vue.component(Divider.name, Divider);
Divider.install = function(app) {
app.use(Base);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.use(Base); 可以删掉了

app.component(Divider.name, Divider);
};

export default Divider;
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 'ant-design-vue/style.js';

Expand All @@ -14,4 +15,5 @@ createApp(App)
.use(Drawer)
.use(Affix)
.use(Alert)
.use(Divider)
.mount('#app');