开始使用
COMPONENTSSpeedDial

SpeedDial 快捷操作 ​

本期保持 PrimeVue 4.5.5 原生 API,不二次封装。导入名 WSpeedDial,与上游 Props、事件、插槽、实例方法完全一致。

交互示例 ​

PREVIEW

基础用法 ​

vue
<script setup lang="ts">
import { ref } from 'vue'
import { WSpeedDial } from '@wizdomt/ui'
import { Add1Icon, FileIcon, ShareIcon } from '@wizdomt/icons'
const selected = ref('选择操作')
const items = [
  { label: '新建', iconComponent: Add1Icon, command: () => (selected.value = '新建') },
  { label: '文件', iconComponent: FileIcon, command: () => (selected.value = '文件') },
  { label: '分享', iconComponent: ShareIcon, command: () => (selected.value = '分享') },
]
</script>

<template>
  <div style="position: relative; height: 260px; width: 100%">
    <p role="status">{{ selected }}</p>
    <WSpeedDial
      :model="items"
      direction="up"
      :style="{ position: 'absolute', bottom: '1rem', left: 'calc(50% - 1.5rem)' }"
      ><template #item="{ item, toggleCallback }"
        ><button
          class="demo-speed-action"
          type="button"
          :aria-label="typeof item.label === 'string' ? item.label : undefined"
          @click="toggleCallback"
        >
          <component :is="item.iconComponent" /></button></template
    ></WSpeedDial>
  </div>
</template>

<style scoped>
.demo-speed-action {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--p-content-border-color);
  border-radius: 50%;
  background: var(--p-content-background);
  color: var(--p-text-color);
}
</style>

说明 ​

  • 组件名:SpeedDial → WSpeedDial(后者仅为别名,WSpeedDial.props 等类型同源)
  • 来源:PrimeVue v4 SpeedDial 文档
  • 完整 Props、事件、Slots、Methods 以上游锁定版本类型声明为准

响应式与无障碍 ​

组件保持 PrimeVue 原生行为。示例容器负责布局;弹出层遵循各组件的 appendTo 配置。键盘与 ARIA 行为来自原生组件,使用方需提供可访问的标签。

主题与暗色模式 ​

通过 WizdomtUI 插件启用 Wizdomt Aura 预设。切换 .dark 选择器即可在暗色下看到本组件的对应表现。

ts
import { createApp } from 'vue'
import { WizdomtUI } from '@wizdomt/ui'
import '@wizdomt/ui/style.css'
import App from './App.vue'

createApp(App).use(WizdomtUI).mount('#app')

如需修改主题色,在使用方传入 theme: { preset: definePreset(WizdomtPreset, ...) },组件本身无需变更。

Wizdomt UI Vue 3 · PrimeVue 4