Skip to content

Button 按钮

轻触,即刻响应。用于触发操作与状态切换。

基础用法

已操作 0 次
查看 Vue 源码
Vue · TypeScript
<script setup lang="ts">
import { AgmButton } from 'augma'
import { shallowRef } from 'vue'

const count = shallowRef(0)
</script>

<template>
  <div class="example-row">
    <AgmButton @click="count++">连接设备</AgmButton>
    <AgmButton variant="outline" @click="count++">次要操作</AgmButton>
    <AgmButton variant="ghost" @click="count++">轻量操作</AgmButton>
    <AgmButton loading>加载中</AgmButton>
    <AgmButton disabled>不可用</AgmButton>
    <output aria-live="polite">已操作 {{ count }} 次</output>
  </div>
</template>

<style scoped>
.example-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.example-stack {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 360px;
}
</style>

API

属性类型默认值说明
variant'primary' | 'outline' | 'ghost''primary'视觉层级
disabledbooleanfalse禁止操作
loadingbooleanfalse处理中,同时禁止重复操作
type'button' | 'submit' | 'reset''button'原生按钮类型

插槽

  • default:按钮文字

键盘操作与使用边界

Tab 聚焦;Enter 或 Space 激活。加载中与禁用状态不接受操作。

安装

ts
import { AgmButton } from 'augma'
import 'augma/style.css'

复制可编辑源码:

sh
pnpm dlx [email protected] add https://augma.yunyoujun.cn/r/button.json