跳到正文
简体中文

用法

import { LandingFaq } from './LandingFaq.jsx'

// Without onAsk a question is "sent" after a short wait. Wire it to your help desk:
<LandingFaq
  locale="en"
  topics={[{ id: 'water', name: 'Watering' }]}
  items={faq}                  // [{ id, topic, q, a }]
  loading={!faq}
  error={faqError}
  onRetry={reloadFaq}
  onAsk={async (question) => (await sendQuestion(question)).ok}
  onFeedback={(id, helpful) => track('faq-helpful', { id, helpful })}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字和示例问题的语言。
topicsArray<{ id, name }>sample topics作为筛选显示的分类,按顺序排列;“全部”会自动排在最前。
itemsArray<{ id, topic, q, a }>sample questions问题和答案。传空数组会显示空状态,并提供提问入口。
defaultQuerystring''搜索框的初始内容,例如从链接带过来的词。
loadingbooleanfalse加载时显示问题列表的骨架。
errorboolean | stringfalse显示带重试按钮的错误提示;传字符串可替换说明。
onAsk(question) => Promise<boolean | void>—发送提问。返回 false 则保留表单,否则显示已发送。
onFeedback(id, helpful) => void—访客反馈某条答案是否有帮助时调用。
onSearch / onRetry(query) => void / () => void—分别在搜索内容变化、点击出错提示里的重试时调用。
labelsobject—替换任意内置文字(键名见 copy.js)。
classNamestring—加在根元素 section 上。

装进你的项目

把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。

LandingFaq.jsxlanding-faq.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/alert-banner/ui/success-check/ui/text-input/ui/textarea/ui/skeleton-shimmer/ui/smooth-accordion/tokens.cssREADME.md

区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。