Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用ListStyle.heroCard将自定义数据添加到ChoicePrompt_Javascript_Node.js_Json_Botframework_Chatbot - Fatal编程技术网

Javascript 如何使用ListStyle.heroCard将自定义数据添加到ChoicePrompt

Javascript 如何使用ListStyle.heroCard将自定义数据添加到ChoicePrompt,javascript,node.js,json,botframework,chatbot,Javascript,Node.js,Json,Botframework,Chatbot,我有一个ChoicePrompt,样式为ListStyle.heroCard,如下所示: import {ChoicePrompt, ListStyle} from 'botbuilder-dialogs'; import {PromptValidator} from 'botbuilder-dialogs/src/prompts/prompt'; import {FoundChoice} from 'botbuilder-dialogs/src/choices/findChoices'; e

我有一个
ChoicePrompt
,样式为
ListStyle.heroCard
,如下所示:

import {ChoicePrompt, ListStyle} from 'botbuilder-dialogs';
import {PromptValidator} from 'botbuilder-dialogs/src/prompts/prompt';
import {FoundChoice} from 'botbuilder-dialogs/src/choices/findChoices';

export class HeroCardChoicePrompt extends ChoicePrompt{
    constructor(dialogId: string, validator?: PromptValidator<FoundChoice>, defaultLocale?: string){
        super(dialogId, validator, defaultLocale)
        this.style = ListStyle.heroCard
    }
}
当用户单击选项时,如何在代码中获取数据
'Lolipop'

当我在bot emulator中检查客户端接收到的JSON对象时,我根本看不到数据
'Lolipop'


使用
ListStyle.heroCard
进行提示,使用
ChoiceFactory.heroCard
生成卡片。您可以在中看到,
选项Factory.heroCard
不使用选项中的操作,而是创建
imBack
操作:


如果您想在提示中提供自定义操作,则需要创建自己的英雄卡,并将其作为提示选项的
提示
字段提供,然后使用
列表样式.none
。不清楚您为什么要这样做,因为
ChoiceFactory
生成的操作将与选项提示中的可用选项相匹配,因此活动不需要隐藏值。

我猜您也发布了此消息:我的答案可以接受吗?按钮应显示:“您能帮我管理吗…”但是return'Lolipop'@TSR-好吧,我刚才解释过,你可以通过创建自己的英雄卡来实现这一点。但你为什么要它这么做?你不是在使用选择提示吗?
choices.push({
    action: {

        text: 'Lolipop',
        displayText: 'Lolipop',
        channelData: 'Lolipop',

        type: 'postBack',
        title:  'Lolipop',
        value:  'Lolipop',

    },
    value: 'Can you please help me to manage...',
    synonyms: []
},)
const buttons: CardAction[] = choices.map(choice => ({
    title: choice.value,
    type: ActionTypes.ImBack,
    value: choice.value
} as CardAction));