跳到主要内容
版本:3.x

CommentList

评论列表

支持情况:

参考文档

类型

ComponentType<CommentListProps>

CommentListProps

参数类型默认值必填说明
commentParamICommentParam评论核心参数
toolbarConfigIToolbarConfig底部 toolbar 的相关配置
isPageScrollbooleantrue滚动方式为页面滚动,若组件作为浮层使用,该参数需设为 false
needToolbarbooleantrue是否需要底部 toolbar ,若使用开发者自定义的底部 toolbar ,该参数需设为 false
addCommentbooleanfalse用于调起评论发布器发布评论,发布成功插入列表第一条,且滚动到列表顶部
detailPathstring点击单条评论跳转的详情页页面 path ,若没有配置则不会发生跳转;配置的前提是列表与详情均是页面级
isFoldedbooleanfalse是否折叠列表,默认全展示
foldNumnumber3折叠后列表展示最大条数,默认 3 条,最多 10 条
viewMorePathstring传入放置评论组件的页面路径,如'/pages/list/index',组件内部会触发跳转逻辑
viewMoreStyleIViewMoreStyle『全部 xx 条』的样式,目前只支持开发者自定义字体颜色
onClickCommentCommonEventFunction绑定点击单条评论的事件,点击单条评论时触发,返回数据为{status, data:{srid}}
onViewMoreCommonEventFunction绑定点击更多事件,若除了页面跳转还需要其他操作,可通过该回调执行;若为浮层,也可使用该回调自定义交互逻辑
onReplyCommonEventFunction评论发布成功时触发,返回数据为 {status, data:{srid}}

API 支持度

API微信小程序百度小程序H5React NativeHarmony
CommentListProps.commentParam✔️
CommentListProps.toolbarConfig✔️
CommentListProps.isPageScroll✔️
CommentListProps.needToolbar✔️
CommentListProps.addComment✔️
CommentListProps.detailPath✔️
CommentListProps.isFolded✔️
CommentListProps.foldNum✔️
CommentListProps.viewMorePath✔️
CommentListProps.viewMoreStyle✔️
CommentListProps.onClickComment✔️
CommentListProps.onViewMore✔️
CommentListProps.onReply✔️

ICommentParam

参数类型默认值必填说明
snidstring被点赞的文章的 id,与 path 参数一一对应
example: "20200101"
titlestring文章标题
pathstring智能小程序内页链接,最长不能超过 194 字符
example: "/pages/index/index"
imagesstring[]['https://b.bdstatic.com/miniapp/images/demo-dog.png']数组第一项用于收藏功能的展示图片

IToolbarConfig

参数类型默认值必填说明
placeholderstring输入框提示文字
moduleListstring['comment', 'like', 'favor', 'share']显示的互动模块,对应默认值分别是:评论数、点赞、收藏、分享
shareIShare若 moduleList 里配置了 share 模块,该参数为必填

IShare

参数类型必填说明
titlestring分享标题
contentstring分享内容
imageUrlstring分享图标
pathstring页面 path ,必须是以 / 开头的完整路径,如果 path 中参数包含中文字符,需对中文字符进行编码

IViewMoreStyle

参数类型默认值必填说明
colorstring"#3388ff"『全部 xx 条』的字体颜色,默认为视觉提供色号,开发者可传入自定义色号