我有下面的代码来渲染多张英雄卡
const hcard = CardFactory.heroCard(
'Neeti Sharma',
'CEO, Moblize.it LLC',
null,
[
{
type: ActionTypes.MessageBack,
title: 'Call',
value: null,
text: 'UpdateCardAction'
},
{
type: ActionTypes.MessageBack,
title: 'Email',
value: null,
text: 'email'
}
]);
await context.sendActivity({ attachments: [hcard, hcard] });
这将一张一张接一张地渲染。如何将其转换为轮播?
答案 0 :(得分:1)
您需要获取所有附件,将它们附加到要发送的回复中,并将“附件”布局设置为Carousel。这是您可以实现的方法:
var reply = activity.CreateReply();
reply.attachment = GetAttachments();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
答案 1 :(得分:0)
为了别人的利益,这就是我现在的做法
const hcard = CardFactory.heroCard(
card._firstName + ' ' + card._lastName,
card._jobTitle + ', ' + card._dept,
null,
[
{
type: ActionTypes.MessageBack,
title: 'Call',
value: null,
text: 'UpdateCardAction'
},
{
type: ActionTypes.MessageBack,
title: 'Email',
value: null,
text: 'email'
}
]);
cardArr.push(hcard)
}
console.log("all the cards are::::" + JSON.stringify(rspVal))
const reply = {
"attachments" : cardArr,
"attachmentLayout" : AttachmentLayoutTypes.Carousel
}
await context.sendActivity(reply);