From 1bf4286bcbb7ca93f898f57d6229cb4a4fb07710 Mon Sep 17 00:00:00 2001 From: wuduoyi Date: Thu, 21 Jul 2022 17:45:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Property=20=E7=9A=84=20title=20?= =?UTF-8?q?=E7=AD=89=E5=B1=9E=E6=80=A7=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E8=A7=A3=E6=9E=90=20Closes=20#4900?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/components/property.md | 4 ++++ packages/amis/src/renderers/Property.tsx | 12 +++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/zh-CN/components/property.md b/docs/zh-CN/components/property.md index fe7e46cb4..a74cf07f5 100644 --- a/docs/zh-CN/components/property.md +++ b/docs/zh-CN/components/property.md @@ -165,6 +165,7 @@ order: 60 { "type": "page", "data": { + "title": "title1", "items": [ { "label": "cpu", @@ -196,6 +197,7 @@ order: 60 }, "body": { "type": "property", + "title": "${title}", "source": "${items}" } } @@ -372,6 +374,8 @@ items 里的属性还支持 `visibleOn` 和 `hiddenOn` 表达式,能隐藏部 | column | `number` | 3 | 每行几列 | | mode | `string` | 'table' | 显示模式,目前只有 'table' 和 'simple' | | separator | `string` | ',' | 'simple' 模式下属性名和值之间的分隔符 | +| title | `string` | | 标题 | +| source | `string` | | 数据源 | | items[].label | `SchemaTpl` | | 属性名 | | items[].content | `SchemaTpl` | | 属性值 | | items[].span | `SchemaTpl` | | 属性值跨几列 | diff --git a/packages/amis/src/renderers/Property.tsx b/packages/amis/src/renderers/Property.tsx index bac9c5ffd..e3327787e 100644 --- a/packages/amis/src/renderers/Property.tsx +++ b/packages/amis/src/renderers/Property.tsx @@ -119,14 +119,7 @@ export default class Property extends React.Component { */ prepareRows() { const {column = 3, items, source, data} = this.props; - const propertyItems = - (items - ? items - : (resolveVariableAndFilter( - source, - data, - '| raw' - ) as Array)) || []; + const propertyItems = items ? items : source || []; const rows: PropertyContent[][] = []; @@ -246,6 +239,7 @@ export default class Property extends React.Component { } @Renderer({ - type: 'property' + type: 'property', + autoVar: true }) export class PropertyRenderer extends Property {}