Skip to content

mms-button 按钮

简述

通用按钮组件,支持多种样式、尺寸与颜色、加载态与禁用态,以及微信开放能力(如获取手机号)。

注意

注意: openType@getphonenumber 等依赖各端实现;H5 / App 部分能力不可用或与小程序表现不同。

平台差异说明

App(vue)App(nvue)H5小程序

基本使用

uvue
<template>
	<view>
		<mms-button type="primary" text="确定" @click="handleClick"></mms-button>
	</view>
</template>

<script setup lang="uts">
	const handleClick = () => {
		console.log('点击了按钮')
	}
</script>

Props

参数说明类型默认值
type样式类型,primary / white / danger / warning / green / blue / gray / black / brownstringprimary
shadow是否显示阴影booleanfalse
width宽度,单位 rpx 或 %string100%
height高度,单位 rpxstring- (自动计算)
btnSize预设尺寸 medium / small / ministring-
size字体大小,单位 rpxnumber | string0 (自动)
bold字体加粗booleanfalse
margin外边距string0
shape形状 circle (圆角) / square (方形) / rightAngle (平角)stringsquare
plain是否空心边框booleanfalse
link是否链接样式booleanfalse
disabled是否禁用booleanfalse
disabledGray禁用后是否灰色背景booleanfalse
loading是否显示加载中booleanfalse
formType表单类型 submit / resetstring-
openType微信开放能力string-
appParameteropenType 额外参数string-
preventClick是否防止重复点击booleanfalse
index索引number | string0

Events

事件名说明回调参数
click点击按钮时触发{ index: number }
getuserinfo获取用户信息detail
getphonenumber获取手机号detail
contact打开客服detail
error错误detail
chooseavatar选择头像detail
launchapp打开appdetail

类型说明

type 可选值

说明
primary主色调 - 蓝色
danger危险 - 红色
warning警告 - 橙色
green成功 - 绿色
blue蓝色
gray灰色
white白色
black黑色
brown棕色

btnSize 预设尺寸

宽度高度
medium368rpx80rpx
small240rpx80rpx
mini116rpx64rpx

插槽

名称说明
default按钮文字

示例

主要样式

uvue
<mms-button type="primary" text="主按钮"></mms-button>
<mms-button type="danger" text="危险按钮"></mms-button>
<mms-button type="warning" text="警告按钮"></mms-button>
<mms-button type="success" text="成功按钮"></mms-button>

空心按钮

uvue
<mms-button type="primary" plain text="空心按钮"></mms-button>

圆角按钮

uvue
<mms-button type="primary" shape="circle" text="圆角按钮"></mms-button>

禁用状态

uvue
<mms-button type="primary" disabled text="禁用按钮"></mms-button>

加载中

uvue
<mms-button type="primary" loading text="加载中"></mms-button>

开放能力 - 获取手机号

uvue
<mms-button
	type="primary"
	open-type="getphonenumber"
	@getphonenumber="handleGetPhone"
	text="获取手机号"
></mms-button>

Released under the MIT License.