Skip to content

Commit d00a971

Browse files
authored
feat: update comment (#2366)
* feat: update comment * fix: children
1 parent 3975cde commit d00a971

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

components/comment/index.jsx

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { inject } from 'vue';
12
import PropsTypes from '../_util/vue-types';
2-
import { getComponentFromProp, getListeners } from '../_util/props-util';
3+
import { getComponent } from '../_util/props-util';
34
import { ConfigConsumerProps } from '../config-provider';
4-
import Base from '../base';
55
export const CommentProps = {
66
actions: PropsTypes.array,
77
/** The element to display as the comment author. */
@@ -19,8 +19,10 @@ export const CommentProps = {
1919
const Comment = {
2020
name: 'AComment',
2121
props: CommentProps,
22-
inject: {
23-
configProvider: { default: () => ConfigConsumerProps },
22+
setup() {
23+
return {
24+
configProvider: inject('configProvider', ConfigConsumerProps),
25+
};
2426
},
2527
methods: {
2628
getAction(actions) {
@@ -41,11 +43,11 @@ const Comment = {
4143
const getPrefixCls = this.configProvider.getPrefixCls;
4244
const prefixCls = getPrefixCls('comment', customizePrefixCls);
4345

44-
const actions = getComponentFromProp(this, 'actions');
45-
const author = getComponentFromProp(this, 'author');
46-
const avatar = getComponentFromProp(this, 'avatar');
47-
const content = getComponentFromProp(this, 'content');
48-
const datetime = getComponentFromProp(this, 'datetime');
46+
const actions = getComponent(this, 'actions');
47+
const author = getComponent(this, 'author');
48+
const avatar = getComponent(this, 'avatar');
49+
const content = getComponent(this, 'content');
50+
const datetime = getComponent(this, 'datetime');
4951

5052
const avatarDom = (
5153
<div class={`${prefixCls}-avatar`}>
@@ -79,9 +81,9 @@ const Comment = {
7981
{contentDom}
8082
</div>
8183
);
82-
const children = this.$slots.default;
84+
const children = this.$slots.default && this.$slots.default();
8385
return (
84-
<div class={prefixCls} {...{ on: getListeners(this) }}>
86+
<div class={prefixCls}>
8587
{comment}
8688
{children ? this.renderNested(prefixCls, children) : null}
8789
</div>
@@ -90,8 +92,7 @@ const Comment = {
9092
};
9193

9294
/* istanbul ignore next */
93-
Comment.install = function(Vue) {
94-
Vue.use(Base);
95-
Vue.component(Comment.name, Comment);
95+
Comment.install = function(app) {
96+
app.component(Comment.name, Comment);
9697
};
9798
export default Comment;

examples/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import '@babel/polyfill';
22
import { createApp } from 'vue';
33
import App from './App.vue';
44
import Button from 'ant-design-vue/button';
5+
import Comment from 'ant-design-vue/comment';
56
import Drawer from 'ant-design-vue/drawer';
67
import Affix from 'ant-design-vue/affix';
78
import Alert from 'ant-design-vue/alert';
@@ -15,6 +16,7 @@ import 'ant-design-vue/style.js';
1516

1617
createApp(App)
1718
.use(Button)
19+
.use(Comment)
1820
.use(ConfigProvider)
1921
.use(Drawer)
2022
.use(Affix)

0 commit comments

Comments
 (0)