Skip to content
On this page

组件库文档 tmui.design

评论 Comment

评论。


🌶️ 评论 Comment 示例效果

查看模拟效果
示例代码
vue
<template>
    <tm-app>
        <tm-sheet>
            <tm-text :font-size="24" _class="font-weight-b" label="基础评论"></tm-text>
        </tm-sheet>
        <tm-comment author="同名自定义" avatar="https://picsum.photos/200/200" time="2022/5/20 13:25"
            content="这是一条最简单的评论内容。"></tm-comment>
        <tm-comment author="同名自定义" avatar="https://picsum.photos/200/200" time="2022/5/20 13:25"
            content="这是一条最简单的评论内容。">
            <template v-slot:actions>
               <view class="flex flex-row norwap">
                    <view class="flex flex-row flex-center pl-16">
                        <tm-icon :font-size="24" name="tmicon-comment-dots"></tm-icon>
                        <tm-text _class="pl-10" :font-size="24" label="125"></tm-text>
                    </view>
                    <view class="flex flex-row flex-center pl-16">
                        <tm-icon :font-size="24" name="tmicon-md-heart"></tm-icon>
                        <tm-text _class="pl-10" :font-size="24" label="125"></tm-text>
                    </view>
               </view>
            </template>
        </tm-comment>
        <tm-sheet>
            <tm-text :font-size="24" _class="font-weight-b" label="可以通过插槽,样式属性配置更个性化"></tm-text>
        </tm-sheet>
        <tm-comment author="同名自定义" avatar="https://picsum.photos/200/200" time="2022/5/20 13:25"
            content="这是一条最简单的评论内容。">
            <tm-comment :border="1" :margin="[0, 8]" author="同名自定义" avatar="https://picsum.photos/200/200"
                time="2022/5/20 13:25" content="这是一条最简单的评论内容。">
                <tm-comment color="grey" linear="left" text :border="1" :margin="[0, 8]" author="同名自定义" avatar="https://picsum.photos/200/200"
                    time="2022/5/20 13:25" content="这是一条最简单的评论内容。">
                    <template v-slot:actions>
                        <view class="flex flex-row norwap">
                            <view class="flex flex-row flex-center pl-16">
                                <tm-icon :font-size="24" name="tmicon-comment-dots"></tm-icon>
                                <tm-text _class="pl-10" :font-size="24" label="125"></tm-text>
                            </view>
                            <view class="flex flex-row flex-center pl-16">
                                <tm-icon :font-size="24" name="tmicon-md-heart"></tm-icon>
                                <tm-text _class="pl-10" :font-size="24" label="125"></tm-text>
                            </view>
                        </view>
                    </template>
                </tm-comment>
            </tm-comment>
        </tm-comment>
        <tm-comment author="同名自定义" avatar="https://picsum.photos/200/200" time="2022/5/20 13:25"
            content="您也可配置输入框进行回复操作。">
            <tm-input></tm-input>
            <view class="flex flex-row flex-row-center-end">
                    <tm-button color="red" :margin="[24,0]" label="确认评论" :font-size="24" :width="160" :height="60"></tm-button>
                    <tm-button color="white" label="取消"  :font-size="24" :width="120" :height="60"></tm-button>
                </view>
        </tm-comment>

        
    </tm-app>
</template>
<script lang="ts" setup>
import { ref } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app";
import tmApp from "@/tmui/components/tm-app/tm-app.vue"
import tmSheet from "@/tmui/components/tm-sheet/tm-sheet.vue"
import tmText from "@/tmui/components/tm-text/tm-text.vue"
import tmIcon from "@/tmui/components/tm-icon/tm-icon.vue"
import tmDivider from "@/tmui/components/tm-divider/tm-divider.vue"
import tmButton from "@/tmui/components/tm-button/tm-button.vue"
import tmComment from "@/tmui/components/tm-comment/tm-comment.vue"
import tmInput from "@/tmui/components/tm-input/tm-input.vue"


</script>

🌶️ 兼容性

APP-VUEAPP-NVUE小程序WEB/H5VUE3/TS
✔️✔️✔️✔️✔️

🌱 参数

本组件含有公共属性 公共属性

参数名类型默认值描述
shadowNumber0卡片投影,0-26
roundNumber4卡片圆角,0-26
widthNumber00即自动
heightNumber00即自动
borderNumber0边框
marginArray[32,8]外间距[x,y]x=左右,y=上下
paddingArray[24, 24]内间距[x,y]x=左右,y=上下
transprentBoolean,Stringfalse
colorStringwhite背景主题颜色名称
borderBottomBoolean,Stringfalse是否显示底部的边线
authorString名称
authorFontSizeNumber26author字体大小,默认26
authorColorStringprimaryauthor主题色
avatarString头像
contentString内容
timeString时间
alignStringright时间和下面的操作按钮是靠左还是靠右:right,left
autoFormatTimeBooleantrue是否格式化时间标签。

🌹 事件

事件名参数返回数据描述
avatar-click
author-click
content-click
time-click

🌽 slot插槽

插槽名参数参数类型描述
author--评论的人
time--评论的时间
content--评论的内容正文
actions--评论的底部插槽,默认是空内容,用于自定底部一些其它布局,比如输入框,先点赞按钮这些或者其它操作按钮等。
default--默认插槽,主要,可以放置任意组件和元素,可以用来嵌套评论组件,把评论组件放置默认插槽中形成嵌套效果。

🥗 ref方法

💏 文档贡献

此页文档由﹎wj潕钶取玳贡献,如果对该框架感兴趣的可以参与我们一同进步!