diff --git a/packages/devui-vue/devui/comment/src/comment-types.ts b/packages/devui-vue/devui/comment/src/comment-types.ts index ea36c2ab8e..a98ed8b723 100644 --- a/packages/devui-vue/devui/comment/src/comment-types.ts +++ b/packages/devui-vue/devui/comment/src/comment-types.ts @@ -1,6 +1,11 @@ import type { PropType, ExtractPropTypes } from 'vue'; + export interface IcommentProps { - [prop: string]: any; + actions?: []; + author?: []; + avatar?: []; + content?: []; + datetime?: []; } // TODO: props 参数的类型需要明确定义 diff --git a/packages/devui-vue/devui/comment/src/comment.tsx b/packages/devui-vue/devui/comment/src/comment.tsx index 2c18cb136b..14a0ba5d85 100644 --- a/packages/devui-vue/devui/comment/src/comment.tsx +++ b/packages/devui-vue/devui/comment/src/comment.tsx @@ -22,18 +22,17 @@ export default defineComponent({ slots: ['actions', 'author', 'avatar', 'content', 'datetime'], setup(props: CommentProps, { slots }) { return () => { - const getAction = (actions: any) => { + const getAction = (actions: []) => { if (!actions || !actions.length) { return null; } - const actionList = actions.map((action: any, index: number) => ( + const actionList = actions.map((action: [], index: number) => (
  • {action}
  • )); return actionList; }; - const actions = props.actions ?? slots.actions?.(); const author = props.author ?? slots.author?.(); const avatar = props.avatar ?? slots.avatar?.(); @@ -42,7 +41,8 @@ export default defineComponent({ const avatarDom = (
    {typeof avatar === 'string' ? comment-avatar : avatar}
    ); - const actionDom = actions ? : null; + const actionsList = Array.isArray(actions) ? actions : [actions]; + const actionDom = actions ? : null; return (
    {avatarDom}