【发布时间】:2020-07-14 19:56:10
【问题描述】:
我正在创建一个自适应卡片,它要求我使用Designer 重复数组中的一些元素。我正在尝试为发票创建项目列表,因此我需要重复购物车中的项目....
我有一个带有这个容器的模板,其中包含需要重复的元素:
{
"type": "Container",
"items": [
{
"type": "Container",
"items": [
{
"$data": "${items}",
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"wrap": true,
"text": "${quantity}"
}
],
"width": "auto"
},
{
"type": "Column",
"spacing": "Medium",
"items": [
{
"type": "TextBlock",
"wrap": true,
"text": "${product.name}"
}
],
"width": "stretch"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "${cost}",
"wrap": true
}
],
"width": "auto"
},
{
"type": "Column",
"id": "chevronDown1",
"spacing": "Small",
"verticalContentAlignment": "Center",
"items": [
{
"type": "Image",
"selectAction": {
"type": "Action.ToggleVisibility",
"title": "collapse",
"targetElements": [
"cardContent1",
"chevronUp1",
"chevronDown1"
]
},
"url": "https://adaptivecards.io/content/down.png",
"width": "20px",
"altText": "collapsed"
}
],
"width": "auto"
},
{
"type": "Column",
"id": "chevronUp1",
"isVisible": false,
"spacing": "Small",
"verticalContentAlignment": "Center",
"items": [
{
"type": "Image",
"selectAction": {
"type": "Action.ToggleVisibility",
"title": "expand",
"targetElements": [
"cardContent1",
"chevronUp1",
"chevronDown1"
]
},
"url": "https://adaptivecards.io/content/up.png",
"width": "20px",
"altText": "expanded"
}
],
"width": "auto"
}
]
},
{
"type": "Container",
"id": "cardContent1",
"isVisible": false,
"items": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"isSubtle": true,
"wrap": true,
"text": "${product.description}"
}
]
}
]
}
],
}
],
}
以及如下所示的示例数据:
{
"items": [
{
"quantity": "1",
"unitCost": "55",
"cost": "55",
"product": {
"name": "Product 1",
"description": "Lorem ipsum dolor sit amet"
}
}, {
"quantity": "2",
"unitCost": "55",
"cost": "55",
"product": {
"name": "Product 2",
"description": "Lorem ipsum dolor sit amet"
}
}
]
}
我关注了example here,但我无法获得相同的效果...我推测这是因为我有嵌套元素。
【问题讨论】:
标签: adaptive-cards