Appearance
Button 按钮
主按钮
vue
<template>
<nex-button type="primary">主按钮</nex-button>
<nex-button plain type="primary">主按钮</nex-button>
</template><template>
<nex-button type="primary">主按钮</nex-button>
<nex-button plain type="primary">主按钮</nex-button>
</template>次按钮
vue
<template>
<nex-button type="default">次按钮</nex-button>
<nex-button plain>次按钮</nex-button>
</template><template>
<nex-button type="default">次按钮</nex-button>
<nex-button plain>次按钮</nex-button>
</template>禁用状态
vue
<template>
<nex-button disabled type="primary">主按钮</nex-button>
<nex-button plain disabled type="primary">主按钮</nex-button>
<nex-button disabled type="default">次按钮</nex-button>
<nex-button plain disabled type="default">次按钮</nex-button>
</template><template>
<nex-button disabled type="primary">主按钮</nex-button>
<nex-button plain disabled type="primary">主按钮</nex-button>
<nex-button disabled type="default">次按钮</nex-button>
<nex-button plain disabled type="default">次按钮</nex-button>
</template>按钮形状
vue
<template>
<nex-button shape="square" type="primary">方块</nex-button>
<nex-button shape="round" type="primary">圆形</nex-button>
</template><template>
<nex-button shape="square" type="primary">方块</nex-button>
<nex-button shape="round" type="primary">圆形</nex-button>
</template>加载状态
vue
<template>
<nex-button loading type="primary"></nex-button>
<nex-button loading type="primary">加载中...</nex-button>
<nex-button :loading="isLoading" type="primary" @click="onChange"
>点击!</nex-button
>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const isLoading = ref(false);
const onChange = () => {
isLoading.value = true;
setTimeout(() => {
isLoading.value = false;
}, 3000);
};
</script><template>
<nex-button loading type="primary"></nex-button>
<nex-button loading type="primary">加载中...</nex-button>
<nex-button :loading="isLoading" type="primary" @click="onChange"
>点击!</nex-button
>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const isLoading = ref(false);
const onChange = () => {
isLoading.value = true;
setTimeout(() => {
isLoading.value = false;
}, 3000);
};
</script>图标按钮
vue
<template>
<nex-button shape="square" type="primary">
<template #icon>
<Star />
</template>
Star
</nex-button>
<nex-button shape="square" plain type="primary">
<template #icon>
<StarFill />
</template>
</nex-button>
</template>
<script setup lang="ts">
import { StarFill, Star } from '@nutui/icons-vue-taro';
</script><template>
<nex-button shape="square" type="primary">
<template #icon>
<Star />
</template>
Star
</nex-button>
<nex-button shape="square" plain type="primary">
<template #icon>
<StarFill />
</template>
</nex-button>
</template>
<script setup lang="ts">
import { StarFill, Star } from '@nutui/icons-vue-taro';
</script>按钮尺寸
vue
<template>
<nex-button size="large" type="primary">大按钮</nex-button>
<nex-button type="primary">正常按钮</nex-button>
<nex-button size="small" type="primary">小按钮</nex-button>
<nex-button size="mini" type="primary">最小按钮</nex-button>
</template><template>
<nex-button size="large" type="primary">大按钮</nex-button>
<nex-button type="primary">正常按钮</nex-button>
<nex-button size="small" type="primary">小按钮</nex-button>
<nex-button size="mini" type="primary">最小按钮</nex-button>
</template>自定义颜色
vue
<template>
<nex-button color="#7232dd">纯颜色</nex-button>
<nex-button color="#7232dd" plain>纯颜色</nex-button>
<nex-button color="linear-gradient(to right, #ff6034, #ee0a24)">
渐变
</nex-button>
</template><template>
<nex-button color="#7232dd">纯颜色</nex-button>
<nex-button color="#7232dd" plain>纯颜色</nex-button>
<nex-button color="linear-gradient(to right, #ff6034, #ee0a24)">
渐变
</nex-button>
</template>文字按钮
vue
<template>
<view class="button-text">
<nex-button size="mini" type="text">
<template #icon>
<Plus />
</template>
新建分组
</nex-button>
</view>
</template>
<script setup lang="ts">
import { Plus } from '@nutui/icons-vue-taro';
</script>
<style lang="less">
.button-text {
--nex-icon-font-size: 50px;
}
</style><template>
<view class="button-text">
<nex-button size="mini" type="text">
<template #icon>
<Plus />
</template>
新建分组
</nex-button>
</view>
</template>
<script setup lang="ts">
import { Plus } from '@nutui/icons-vue-taro';
</script>
<style lang="less">
.button-text {
--nex-icon-font-size: 50px;
}
</style>Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | 类型,可选值为 primary info warning danger success default | string | default |
| size | 尺寸,可选值为 large small mini | ||
| shape | 形状,可选值为 square round | string | round |
| color | 按钮颜色,支持传入 linear-gradient 渐变色 | string | - |
| plain | 是否为幽灵按钮 | boolean | false |
| disabled | 是否禁用按钮 | boolean | false |
| loading | 按钮 loading 状态 | boolean | false |
Slots
| 名称 | 说明 |
|---|---|
| default | 按钮内容 |
| icon | 按钮图标 |
Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| click | 点击按钮时触发 | event: MouseEvent |