用法
import { BookingServices } from './BookingServices.jsx'
// Without callbacks it runs on the sample salon menu. Wire it to your booking flow:
<BookingServices
locale="en"
currency="USD"
categories={[{ id: 'cut', name: 'Cut & style', icon: 'scissors' }, { id: 'colour', name: 'Colour', icon: 'drop' }]}
services={menu.services} // [{ id, category, name, minutes, price, popular?, icon? }]
stylists={menu.stylists} // [{ id, name, role, avatar?, look?, tone?, does? }]
defaultValue={['cut']} // without it the popular service starts chosen
loading={menu.loading}
error={menu.error}
onRetry={menu.reload}
onContinue={async ({ services, stylist, minutes, price }) => goToTimes({ services, stylist, minutes })}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例服务项目的语言。 |
services | Array<{ id, category, name, minutes, price, popular?, icon? }> | sample menu | 可预约的服务;icon 可替换所属分类的图标。传空数组时显示空状态。 |
categories | Array<{ id, name, icon? }> | sample categories | 分类标签及顺序,没有服务的分类不显示。icon 是该类卡片上的图标:图标名、“drop”或节点。 |
stylists | Array<{ id, name, role, avatar?, look?: 'short' | 'long' | 'bun', tone?, does? }> | sample stylists | 可选的人员。avatar(图片地址)替换手绘头像。`does` 列出其负责的分类;所选服务超出范围时该人员变灰。 |
currency | string | by locale | 所有价格使用的 ISO 货币代码。 |
defaultValue | string[] | the popular service | 初始选中的服务。 |
defaultStylist | string | the first stylist | 初始选中的人员;'any' 表示不指定。 |
loading | boolean | false | 加载时显示服务列表的骨架。 |
error | boolean | string | false | 显示带重试按钮的错误提示;传字符串可替换说明。 |
onChange | (ids) => void | — | 所选服务变化时调用。 |
onStylistChange | (id) => void | — | 发型师变化时调用,区块自动改为不指定('any')时也会调用。 |
onContinue | ({ services, stylist, minutes, price }) => Promise | void | — | 访客进入选时间步骤;返回 Promise 时按钮会等待其完成。 |
onRetry / onCall | () => void | — | 分别在错误提示和空状态中调用。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素上;其他属性也会传给根元素。 |
装进你的项目
把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。
BookingServices.jsxbooking-services.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/rolling-number/ui/alert-banner/ui/success-check/ui/skeleton-shimmer/ui/sliding-tabs/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。