跳到正文
简体中文

用法

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'内置文字和示例服务项目的语言。
servicesArray<{ id, category, name, minutes, price, popular?, icon? }>sample menu可预约的服务;icon 可替换所属分类的图标。传空数组时显示空状态。
categoriesArray<{ id, name, icon? }>sample categories分类标签及顺序,没有服务的分类不显示。icon 是该类卡片上的图标:图标名、“drop”或节点。
stylistsArray<{ id, name, role, avatar?, look?: 'short' | 'long' | 'bun', tone?, does? }>sample stylists可选的人员。avatar(图片地址)替换手绘头像。`does` 列出其负责的分类;所选服务超出范围时该人员变灰。
currencystringby locale所有价格使用的 ISO 货币代码。
defaultValuestring[]the popular service初始选中的服务。
defaultStyliststringthe first stylist初始选中的人员;'any' 表示不指定。
loadingbooleanfalse加载时显示服务列表的骨架。
errorboolean | stringfalse显示带重试按钮的错误提示;传字符串可替换说明。
onChange(ids) => void—所选服务变化时调用。
onStylistChange(id) => void—发型师变化时调用,区块自动改为不指定('any')时也会调用。
onContinue({ services, stylist, minutes, price }) => Promise | void—访客进入选时间步骤;返回 Promise 时按钮会等待其完成。
onRetry / onCall() => void—分别在错误提示和空状态中调用。
labelsobject—替换任意内置文字(键名见 copy.js)。
classNamestring—加在根元素上;其他属性也会传给根元素。

装进你的项目

把指令粘贴给 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 会一起装进同一个文件夹。