1
+ import { inject } from 'vue' ;
1
2
import PropsTypes from '../_util/vue-types' ;
2
- import { getComponentFromProp , getListeners } from '../_util/props-util' ;
3
+ import { getComponent } from '../_util/props-util' ;
3
4
import { ConfigConsumerProps } from '../config-provider' ;
4
- import Base from '../base' ;
5
5
export const CommentProps = {
6
6
actions : PropsTypes . array ,
7
7
/** The element to display as the comment author. */
@@ -19,8 +19,10 @@ export const CommentProps = {
19
19
const Comment = {
20
20
name : 'AComment' ,
21
21
props : CommentProps ,
22
- inject : {
23
- configProvider : { default : ( ) => ConfigConsumerProps } ,
22
+ setup ( ) {
23
+ return {
24
+ configProvider : inject ( 'configProvider' , ConfigConsumerProps ) ,
25
+ } ;
24
26
} ,
25
27
methods : {
26
28
getAction ( actions ) {
@@ -41,11 +43,11 @@ const Comment = {
41
43
const getPrefixCls = this . configProvider . getPrefixCls ;
42
44
const prefixCls = getPrefixCls ( 'comment' , customizePrefixCls ) ;
43
45
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' ) ;
49
51
50
52
const avatarDom = (
51
53
< div class = { `${ prefixCls } -avatar` } >
@@ -79,9 +81,9 @@ const Comment = {
79
81
{ contentDom }
80
82
</ div >
81
83
) ;
82
- const children = this . $slots . default ;
84
+ const children = this . $slots . default && this . $slots . default ( ) ;
83
85
return (
84
- < div class = { prefixCls } { ... { on : getListeners ( this ) } } >
86
+ < div class = { prefixCls } >
85
87
{ comment }
86
88
{ children ? this . renderNested ( prefixCls , children ) : null }
87
89
</ div >
@@ -90,8 +92,7 @@ const Comment = {
90
92
} ;
91
93
92
94
/* 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 ) ;
96
97
} ;
97
98
export default Comment ;
0 commit comments