For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/templates/ask-human-card.md.

问询卡

AskHumanCard 是展示在回答气泡内的一组选项按钮,适合流程需要用户主动确认选择或执行固定跳转的场景。

AskHumanCard 问询卡效果

示例

import { AskHumanCard, type AskHumanCardItem } from '@doubao-dev/template';

const items: AskHumanCardItem[] = [
  {
    key: 'latte',
    text: '轻芝士拿铁',
    onClick: () => console.log('select latte')
  },
  {
    key: 'grape',
    text: '冰葡萄特饮',
    onClick: () => console.log('select grape')
  },
  {
    key: 'skip',
    text: '跳过',
    showArrow: 'right',
    onClick: () => console.log('skip')
  }
];

export default function CoffeeQuestionCard() {
  return <AskHumanCard items={items} />;
}

固定跳转场景使用 jump 变体。1 个选项占满一行,2 个选项平分一行;3 个及以上选项会回退为纵向排列:

<AskHumanCard
  variant="jump"
  items={[
    {
      key: 'recharge',
      text: '去充值',
      showArrow: 'right',
      onClick: () => console.log('open recharge')
    }
  ]}
/>

跳转外部应用时,将选项的 openType 设置为 'launchApp',并通过 launchAppUrl 传入 deeplink:

<AskHumanCard
  variant="jump"
  items={[
    {
      key: 'open-app',
      text: '打开外部应用',
      showArrow: 'right',
      openType: 'launchApp',
      launchAppUrl: 'your-app://path',
      onLaunchApp: (result) => console.log('launch app success', result),
      onLaunchAppError: (error) => console.error('launch app failed', error)
    }
  ]}
/>

主要 Props

Prop类型说明
itemsAskHumanCardItem[]选项列表
variant'suggestion' | 'jump'选项行为和排列语义,默认 suggestion
onClick(event) => void卡片根节点点击事件

AskHumanCardItem

Prop类型必填说明
keyTemplateKey否选项唯一标识
textTemplateText否选项文案
loadingboolean否是否展示加载状态;加载时禁用点击
openType'launchApp'否设置为 'launchApp' 时,点击选项跳转外部应用
launchAppUrlstring否外部应用的 deeplink;openType="launchApp" 时必填
onLaunchApp(result: LaunchAppResult) => void否成功跳转外部应用时触发
onLaunchAppError(error: unknown) => void否跳转外部应用失败时触发
showArrow'left' | 'right' | 'none'否箭头位置,默认不展示
onClick(event?) => void否点击选项时触发

使用说明

  • 选项文案通过 text 配置。
  • showArrow 支持 'left'、'right' 和 'none',默认不展示箭头。
  • loading: true 时展示加载状态并禁用该选项的点击。
  • 跳转外部应用时,必须同时配置 openType: 'launchApp' 和 launchAppUrl。
  • 外部应用跳转结果分别通过 onLaunchApp 和 onLaunchAppError 回调。
  • 普通候选项使用默认的 suggestion;单个或两个固定跳转入口使用 variant="jump"。