n-button 按钮

基于uniapp的button基础上做了统一的优化


1.微信小程序设置了form-type的button只会对当前组件中的form有效

平台兼容性

AppH5微信小程序支付宝小程序百度小程序头条小程序QQ小程序

示例代码

基础使用

<n-button>默认按钮</n-button>
<n-button type="primary">主要按钮</n-button>
<n-button type="warn">警告按钮</n-button>
<n-button type="text">文本/图标按钮</n-button>

文本前/后标

<n-button type="text"  text="按钮">
	<template #prefix>前标</template>
</n-button>

<n-button type="text" text="按钮">
	<template #suffix>后标</template>
</n-button>

API

属性

参数说明类型默认值可选值
*type按钮类型
text: 文本按钮或者图标按钮
Stringdefaultdefault
primary
warn
text
text文本String--
text-style自定义文本样式Object{fontSize: '26rpx',fontWeight: 'bold'}与vue写法一致
background-color按钮背景色String与type相关与css相同
disabled-background-color禁用时背景色String--
disabled-color禁用时文本颜色String--
border-width边框宽度String0rpx-
border-color边框颜色String--
border-radius边框圆角String10rpx-
width宽度String--
height高度String--
*hover-class指定按钮按下去的样式类;
微信小程序:须要放到页面中或App.vue中,且不能放在scoped中,在页面中的组件A中使用,在组件A中定义样式类则无效
String执行背景色的opacity: 0.7;none
...其他同uniapp中button---

事件

参数说明类型默认值可选值
...其他同uniapp中button---

插槽

参数说明类型默认值可选值
prefixtext前置内容---
suffixtext后置内容---