From ed34e3268edd26e9c3739f82d865a5f10c0a639c Mon Sep 17 00:00:00 2001 From: lishiyao Date: Wed, 6 Apr 2022 16:55:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9comment=20jest?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/comment/src/comment-types.ts | 7 ++++++- packages/devui-vue/devui/comment/src/comment.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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}