常用组件
按钮 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>
🌶️ 兼容性
平台兼容
H5 | uniAPP | 小程序 | version |
---|---|---|---|
☑️ | ☑️ | ☑️ | ☑️ |
🌱 参数
参数名 | 类型 | 默认值 | 描述 |
---|---|---|---|
size | string | "n" | 尺寸大小,可选值:s/m/n/g/xs |
skin | string | "normal" | 样式可选值:thin/outlined/text/normal/dashed |
borderWidth | string|number|Array<string | number> | 1 | 遵循规则:string或者[x]:全部边线[x,x]左右边线,上下边线[x,x,x]左,上,右[x,x,x,x]左,上,右,下 |
round | string|number|Array<string | number> | '' | 圆角半径左上,右上,右下,左下 |
rounded | boolean | false | 50%圆角 |
width | string|number | "" | - |
height | string|number | "" | - |
openType | string | "" | - |
block | boolean | false | - |
disabled | boolean | false | - |
icon | string | "" | - |
iconSize | string | "" | - |
btnIcon | boolean | false | 是否开启仅图标按钮模式,宽和高相等 |
loading | boolean | false | - |
fontSize | string | "" | - |
color | string | "" | 自定义主题颜色 |
bgColor | string | "" | 自定义背景 |
darkBgColor | string | "" | - |
fontColor | string | "" | - |
darkFontColorColor | string | "" | - |
linear | string[] | ()=>[] | 渐变,前面的color,bgColor,darkBgColor失效 |
shadow | string|number|Array<string> | '' | 数字或者字符串时自动计算投影,它会投影大小数组时(必须为4),第一个x,第二为y,第三个为大小,第四个为投影颜色空字符串时,取全局配置,如果不想投影设置为none即可. |
formType | string | "" | - |
disableHover | boolean | false | 禁止hover效果,点按没有hover效果,有时可能不需要。 |
url | string | "" | 跳转的地址链接,出现时点击click会跳转以/pages开头。 |
navigatorMode | string | "navigateTo" | url跳转模式 |
appParameter | string | "" | - |
lang | string | "en" | - |
sessionFrom | string | "" | - |
sendMessageTitle | string | "" | - |
sendMessagePath | string | "" | - |
sendMessageImg | string | "" | - |
showMessageCard | boolean | false | - |
groupId | string | "" | - |
guildId | string | "" | - |
publicId | string | "" | - |
dataImId | string | "" | - |
dataImType | string | "" | - |
dataGoodsId | string | "" | - |
dataOrderId | string | "" | - |
dataBizLine | string | "" | - |
🌹 事件
事件名 | 参数 | 返回数据 | 描述 |
---|---|---|---|
click | 名称:evt,事件参数, | - | 点击事件 |
getphonenumber | - | - | - |
getuserinfo | - | - | - |
error | - | - | - |
opensetting | - | - | - |
launchapp | - | - | - |
contact | - | - | - |
chooseavatar | - | - | - |
agreeprivacyauthorization | - | - | - |
addgroupapp | - | - | - |
chooseaddress | - | - | - |
chooseinvoicetitle | - | - | - |
subscribe | - | - | - |
login | - | - | - |
im | - | - | - |
🌽 slot插槽
插槽名 | 数据 | 描述 |
---|---|---|
icon | - | icon图标 |
default | - | 默认插槽 |
🥗 ref方法
方法名 | 参数 | 返回值 | 描述 |
---|