我的卡片上有一个切换按钮,在底部显示另一个部分,其中包含一些文本信息,在这里我想显示包含 2 个项目的项目符号列表。
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ToggleVisibility",
"title": "tips",
"tooltip": "show tips",
"targetElements": [
"HelpToggle"
]
}
]
}
],
"width": "stretch"
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": 65,
"items": [
{
"type": "TextBlock",
"text": "EXAMPLE CARD TITLE",
"wrap": true,
"size": "ExtraLarge",
"horizontalAlignment": "Left",
"weight": "Bolder",
"spacing": "None"
}
],
"verticalContentAlignment": "Center",
"spacing": "ExtraLarge"
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "ColumnSet"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "${help}",
"wrap": true
}
],
"style": "accent",
"bleed": true,
"spacing": "None",
"isVisible": false,
"id": "HelpToggle"
}
]
}
在自适应卡设计器中预览此卡显示正确:
问题是,当我尝试在团队中的卡片上呈现项目符号列表时,仅呈现粗体标记,而项目符号标记被忽略:
这是我渲染卡片的函数:
async createTipsCard(context, tipsText) {
const template = new ACData.Template(tipsCard);
const temp = template.expand({
$root: {
// help: tipsText
help: "Bullet list with tips: \r- **Tip 1**: Dummy text for tip #1. \r- **Tip 2**: Dummy text for tip #2."
}
});
await context.sendActivity({ text: '', attachments: [CardFactory.adaptiveCard(temp)] });
}
tipsText - 我在函数中发送的这个参数包含我想要在切换部分中呈现的文本字符串 “带有提示的项目符号列表: - 提示 1:提示 #1 的虚拟文本。 - 提示 2:提示 #2 的虚拟文本。”
如果我通过 TipsText 变量提供此文本,则项目符号不会呈现在卡片中, 如果我直接将文本作为值提供给 $root.help 属性,则会呈现项目符号
$root: {
// help: tipsText
help: "Bullet list with tips: \r- **Tip 1**: Dummy text for tip #1. \r- **Tip 2**: Dummy text for tip #2." // this way bulleted list is rendered
}
总结一下:从变量值添加文本不会渲染项目符号,而提供相同的文本直接渲染项目符号。