Skip to content
On this page
你当前查看的文档是tmui3.2.0(已不再支持NVUE)
[tmui3.1.x nvue点我] [tmui4.x uniappx原生开发代替nvue]

常用组件

按钮 TmButton

圆角,主题可通过配置统一设置或者动态全局设置,使设计风格统一并保持一致性。让你的风格独一无二。

🌶️ 示例

查看模拟效果
示例模板
vue
<template>
    <tm-sheet>
        <tm-text font-size="36" class="text-weight-b mt-16">按钮 TmButton</tm-text>
        <view class="mb-16">
            <tm-text>样式丰富塑造性好。</tm-text>
        </view>

        <view class="gap-15 flex flex-col">
            <tm-button block>正常</tm-button>
            <tm-button block color="warn">警告</tm-button>
            <tm-button block color="error">错误</tm-button>
            <tm-button block color="success">成功</tm-button>
            <tm-button block color="danger">危险</tm-button>
            <tm-button block color="info">次要</tm-button>
        </view>
    </tm-sheet>

    <tm-sheet>
        <tm-text font-size="36" class="text-weight-b">大小</tm-text>
        <view class="flex flex-row flex-row-top-start flex-wrap gap-15 mt-16">
            <tm-button size="xs">极小</tm-button>
            <tm-button size="s"></tm-button>
            <tm-button size="m">中等</tm-button>
            <tm-button>默认</tm-button>
            <tm-button size="g">大按钮</tm-button>
        </view>
    </tm-sheet>

    <tm-sheet class="gap-15 flex flex-col">
        <tm-text font-size="36" class="text-weight-b flex">状态</tm-text>
        <tm-button block :loading="true">加载中</tm-button>
        <tm-button block :disabled="true">禁用</tm-button>
    </tm-sheet>

    <tm-sheet>
        <tm-text font-size="36" class="text-weight-b mb-16 d-block">图标按钮</tm-text>
        <view class="flex flex-row flex-row-top-start flex-wrap gap-15">
            <tm-button icon="thumb-up-fill" size="n" btnIcon width="80" rounded></tm-button>
            <tm-button icon="reply-line" color="error" size="n" btnIcon width="80" rounded></tm-button>
            <tm-button icon="verified-badge-fill" skin="outlined" iconSize="52" size="n" btnIcon width="80"
                rounded></tm-button>
            <tm-button loading skin="outlined" btnIcon width="80" rounded></tm-button>
        </view>
    </tm-sheet>

    <tm-sheet>
        <tm-text font-size="36" class="text-weight-b mb-16 d-block">按钮样式</tm-text>
        <view class="flex flex-row flex-row-top-start flex-wrap gap-15">
            <tm-button loading skin="outlined">加载中</tm-button>
            <tm-button skin="dashed" :round="[20, 0, 20, 0]">异形</tm-button>
            <tm-button color="#4300B1" :linear="['45deg', '#A531DC', '#4300B1']">渐变</tm-button>
            <tm-button skin="text">文本</tm-button>
            <tm-button skin="thin">浅色</tm-button>
        </view>
    </tm-sheet>
    <tm-sheet>
        <tm-text font-size="36" class="text-weight-b mb-16 d-block">渐变按钮</tm-text>
        <view class="gap-15 flex flex-col">
            <tm-button block :linear="['to right', '#FFEB3A', '#4DEF8E']">按钮</tm-button>
            <tm-button block :linear="['to right', '#00B960', '#00552C']">按钮</tm-button>
            <tm-button block :linear="['to right', '#DD7BFF', '#FF6C6C']">按钮</tm-button>
            <tm-button block :linear="['to right', '#FFC328', '#E20000']">按钮</tm-button>
        </view>
    </tm-sheet>
</template>

<script setup>
import { ref } from "vue";
</script>

<style></style>

🌶️ 兼容性

平台兼容

H5uniAPP小程序version
☑️☑️☑️☑️

🌱 参数

参数名类型默认值描述
sizestring"n"尺寸大小,可选值:s/m/n/g/xs
skinstring"normal"样式可选值:thin/outlined/text/normal/dashed
borderWidthstring|number|Array<string | number>1遵循规则:string或者[x]:全部边线[x,x]左右边线,上下边线[x,x,x]左,上,右[x,x,x,x]左,上,右,下
roundstring|number|Array<string | number>''圆角半径左上,右上,右下,左下
roundedbooleanfalse50%圆角
widthstring|number""-
heightstring|number""-
openTypestring""-
blockbooleanfalse-
disabledbooleanfalse-
iconstring""-
iconSizestring""-
btnIconbooleanfalse是否开启仅图标按钮模式,宽和高相等
loadingbooleanfalse-
fontSizestring""-
colorstring""自定义主题颜色
bgColorstring""自定义背景
darkBgColorstring""-
fontColorstring""-
darkFontColorColorstring""-
linearstring[]()=>[]渐变,前面的color,bgColor,darkBgColor失效
shadowstring|number|Array<string>''数字或者字符串时自动计算投影,它会投影大小数组时(必须为4),第一个x,第二为y,第三个为大小,第四个为投影颜色空字符串时,取全局配置,如果不想投影设置为none即可.
formTypestring""-
disableHoverbooleanfalse禁止hover效果,点按没有hover效果,有时可能不需要。
urlstring""跳转的地址链接,出现时点击click会跳转以/pages开头。
navigatorModestring"navigateTo"url跳转模式
appParameterstring""-
langstring"en"-
sessionFromstring""-
sendMessageTitlestring""-
sendMessagePathstring""-
sendMessageImgstring""-
showMessageCardbooleanfalse-
groupIdstring""-
guildIdstring""-
publicIdstring""-
dataImIdstring""-
dataImTypestring""-
dataGoodsIdstring""-
dataOrderIdstring""-
dataBizLinestring""-

🌹 事件

事件名参数返回数据描述
click名称:evt,事件参数,-点击事件
getphonenumber---
getuserinfo---
error---
opensetting---
launchapp---
contact---
chooseavatar---
agreeprivacyauthorization---
addgroupapp---
chooseaddress---
chooseinvoicetitle---
subscribe---
login---
im---

🌽 slot插槽

插槽名数据描述
icon-icon图标
default-默认插槽

🥗 ref方法

方法名参数返回值描述