Skip to content

Stateful Button ​

Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码

预览 ​

用法 ​

vue
<script setup lang="ts">
import { ref, onBeforeUnmount } from 'vue'
import { StatefulButton } from 'beui-vue'
const state = ref<'idle'|'loading'|'success'>('idle')
let timer: ReturnType<typeof setTimeout>
function save() {
  state.value = 'loading'
  timer = setTimeout(() => { state.value = 'success' }, 700)
}
onBeforeUnmount(() => clearTimeout(timer))
</script>
<template><StatefulButton :state="state" loading-text="保存中" success-text="已保存" @click="save">保存更改</StatefulButton></template>

API ​

state 接受 idle、loading、success、error。loadingText、successText 和 errorText 提供状态文案。忙碌时禁用重复提交。

上游变体 ​

还原验收 ​

基于 beUI 的独立 Vue 移植,依 MIT 许可证分发。